Skip to content

Commit

Permalink
terminal: clear substitute path rules cache when config is used
Browse files Browse the repository at this point in the history
Fixes #3565
  • Loading branch information
aarzilli committed Nov 16, 2023
1 parent 938cb6e commit cfa98ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/terminal/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1488,3 +1488,26 @@ func TestListPackages(t *testing.T) {
}
})
}

func TestSubstitutePathAndList(t *testing.T) {
// checks that substitute path rules do not remain cached after a -clear.
// See issue #3565.
withTestTerminal("math", t, func(term *FakeTerminal) {
term.MustExec("break main.main")
term.MustExec("continue")
fixturesDir, _ := filepath.Abs(test.FindFixturesDir())
term.MustExec("config substitute-path " + fixturesDir + " /blah")
out, _ := term.Exec("list")
t.Logf("list output %s", out)
if !strings.Contains(out, "/blah/math.go") {
t.Fatalf("bad output")
}
term.MustExec("config substitute-path -clear")
term.MustExec("config substitute-path " + fixturesDir + " /blah2")
out, _ = term.Exec("list")
t.Logf("list output %s", out)
if !strings.Contains(out, "/blah2/math.go") {
t.Fatalf("bad output")
}
})
}
1 change: 1 addition & 0 deletions pkg/terminal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func configureCmd(t *Term, ctx callContext, args string) error {
t.substitutePathRulesCache = nil
switch args {
case "-list":
return configureList(t)
Expand Down

0 comments on commit cfa98ed

Please sign in to comment.