Allow relative paths for setlocal (#2253)
This commit is contained in:
1 parent
0283b2a71a
commit
40e7fb8e9e
2 files changed
+14
-4
No files matched your search
@@ -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 <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 `setlocal` command no longer requires absolute paths (#2253).
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user