handle abs paths in rename
This commit is contained in:
parent
0a22e7c5c8
commit
707d927788
12
eval.go
12
eval.go
@ -507,7 +507,7 @@ func insert(app *app, arg string) {
|
|||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(app.ui.cmdPrefix, "create path"):
|
case strings.HasPrefix(app.ui.cmdPrefix, "create"):
|
||||||
normal(app)
|
normal(app)
|
||||||
|
|
||||||
if arg == "y" {
|
if arg == "y" {
|
||||||
@ -1126,7 +1126,11 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
oldPath := filepath.Join(wd, curr.Name())
|
oldPath := filepath.Join(wd, curr.Name())
|
||||||
newPath := filepath.Join(wd, s)
|
|
||||||
|
newPath := filepath.Clean(s)
|
||||||
|
if !filepath.IsAbs(newPath) {
|
||||||
|
newPath = filepath.Join(wd, newPath)
|
||||||
|
}
|
||||||
|
|
||||||
if oldPath == newPath {
|
if oldPath == newPath {
|
||||||
return
|
return
|
||||||
@ -1137,7 +1141,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
|
|
||||||
newDir := filepath.Dir(newPath)
|
newDir := filepath.Dir(newPath)
|
||||||
if _, err := os.Stat(newDir); os.IsNotExist(err) {
|
if _, err := os.Stat(newDir); os.IsNotExist(err) {
|
||||||
app.ui.cmdPrefix = "create path " + newDir + "?[y/N]"
|
app.ui.cmdPrefix = "create " + newDir + "?[y/N]"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1148,7 +1152,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if newStat, err := os.Stat(newPath); !os.IsNotExist(err) && !os.SameFile(oldStat, newStat) {
|
if newStat, err := os.Stat(newPath); !os.IsNotExist(err) && !os.SameFile(oldStat, newStat) {
|
||||||
app.ui.cmdPrefix = "replace " + s + "?[y/N]"
|
app.ui.cmdPrefix = "replace " + newPath + "?[y/N]"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user