From 40e7fb8e9eb2f6cfae2326da242aa80e765d9520 Mon Sep 17 00:00:00 2001 From: CatsDeservePets <145048791+CatsDeservePets@users.noreply.github.com> Date: Fri, 7 Nov 2025 23:58:59 +0100 Subject: [PATCH] Allow relative paths for `setlocal` (#2253) --- CHANGELOG.md | 1 + eval.go | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96be5e64..d8b5314f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). - Logs generated by `-log ` now get appended to `` instead of overwriting it (#2215). - 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 diff --git a/eval.go b/eval.go index 2c322f9b..1bc605c1 100644 --- a/eval.go +++ b/eval.go @@ -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)