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

+1
View File
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- `yes-no-prompts` now use the same design everywhere (#2212). - `yes-no-prompts` now use the same design everywhere (#2212).
- Logs generated by `-log <path>` now get appended to `<path>` instead of overwriting it (#2215). - Logs generated by `-log <path>` now get appended to `<path>` instead of overwriting it (#2215).
- The `showbinds` menu now hides the redundant `mode` column (#2226) (#2228) and omits already typed keys (#2249). - The `showbinds` menu now hides the redundant `mode` column (#2226) (#2228) and omits already typed keys (#2249).
- The `setlocal` command no longer requires absolute paths (#2253).
### Added ### Added
+13 -4
View File
@@ -465,13 +465,22 @@ func (e *setExpr) eval(app *app, _ []string) {
} }
func (e *setLocalExpr) eval(app *app, _ []string) { func (e *setLocalExpr) eval(app *app, _ []string) {
e.path = replaceTilde(e.path) recursive := strings.HasSuffix(e.path, string(os.PathSeparator)) && e.path != string(os.PathSeparator)
if !filepath.IsAbs(e.path) { if recursive {
app.ui.echoerr("setlocal: path should be absolute") e.path = strings.TrimSuffix(e.path, string(os.PathSeparator))
return
} }
var err error 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 { switch e.opt {
case "dircounts", "nodircounts", "dircounts!": case "dircounts", "nodircounts", "dircounts!":
err = applyLocalBoolOpt(gLocalOpts.dircounts, gOpts.dircounts, e) err = applyLocalBoolOpt(gLocalOpts.dircounts, gOpts.dircounts, e)