Skip to content

Commit 650f2d5

Browse files
authored
terminal: clear substitute path rules cache when config is used (#3567)
Fixes #3565
1 parent a8ee87e commit 650f2d5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pkg/terminal/command_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,3 +1488,29 @@ func TestListPackages(t *testing.T) {
14881488
}
14891489
})
14901490
}
1491+
1492+
func TestSubstitutePathAndList(t *testing.T) {
1493+
// checks that substitute path rules do not remain cached after a -clear.
1494+
// See issue #3565.
1495+
if runtime.GOOS == "windows" {
1496+
t.Skip("test is not valid on windows due to path separators")
1497+
}
1498+
withTestTerminal("math", t, func(term *FakeTerminal) {
1499+
term.MustExec("break main.main")
1500+
term.MustExec("continue")
1501+
fixturesDir, _ := filepath.Abs(test.FindFixturesDir())
1502+
term.MustExec("config substitute-path " + fixturesDir + " /blah")
1503+
out, _ := term.Exec("list")
1504+
t.Logf("list output %s", out)
1505+
if !strings.Contains(out, "/blah/math.go") {
1506+
t.Fatalf("bad output")
1507+
}
1508+
term.MustExec("config substitute-path -clear")
1509+
term.MustExec("config substitute-path " + fixturesDir + " /blah2")
1510+
out, _ = term.Exec("list")
1511+
t.Logf("list output %s", out)
1512+
if !strings.Contains(out, "/blah2/math.go") {
1513+
t.Fatalf("bad output")
1514+
}
1515+
})
1516+
}

pkg/terminal/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
)
1212

1313
func configureCmd(t *Term, ctx callContext, args string) error {
14+
t.substitutePathRulesCache = nil
1415
switch args {
1516
case "-list":
1617
return configureList(t)

0 commit comments

Comments
 (0)