Allow relative paths for setlocal (#2253)

This commit is contained in:
CatsDeservePets authored and GitHub committed 2025-11-07 23:58:59 +01:00
1 parent 0283b2a71a
commit 40e7fb8e9e
2 files changed
+14 -4

No files matched your search

+13 -4
View File
@@ -465,13 +465,22 @@ func (e *setExpr) eval(app *app, _ []string) {
}
func (e *setLocalExpr) eval(app *app, _ []string) {
e.path = replaceTilde(e.path)
if !filepath.IsAbs(e.path) {
app.ui.echoerr("setlocal: path should be absolute")
return
recursive := strings.HasSuffix(e.path, string(os.PathSeparator)) && e.path != string(os.PathSeparator)
if recursive {
e.path = strings.TrimSuffix(e.path, string(os.PathSeparator))
}
var err error
e.path, err = filepath.Abs(replaceTilde(e.path))
if err != nil {
app.ui.echoerrf("setlocal: %s", err)
return
}
if recursive && e.path != string(os.PathSeparator) {
e.path += string(os.PathSeparator)
}
switch e.opt {
case "dircounts", "nodircounts", "dircounts!":
err = applyLocalBoolOpt(gLocalOpts.dircounts, gOpts.dircounts, e)