mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-10 23:57:43 +02:00
quote config file when editing
This commit is contained in:
parent
b8ad1883f5
commit
1e48afeb8f
@ -255,7 +255,7 @@ func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error) {
|
|||||||
return nil, errors.New("No editor defined in $VISUAL, $EDITOR, or git config")
|
return nil, errors.New("No editor defined in $VISUAL, $EDITOR, or git config")
|
||||||
}
|
}
|
||||||
|
|
||||||
splitCmd := str.ToArgv(fmt.Sprintf("%s %s", editor, filename))
|
splitCmd := str.ToArgv(fmt.Sprintf("%s %s", editor, c.Quote(filename)))
|
||||||
|
|
||||||
return c.PrepareSubProcess(splitCmd[0], splitCmd[1:]...), nil
|
return c.PrepareSubProcess(splitCmd[0], splitCmd[1:]...), nil
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,28 @@ func TestOSCommandEditFile(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"file/with space",
|
||||||
|
func(name string, args ...string) *exec.Cmd {
|
||||||
|
if name == "which" {
|
||||||
|
return exec.Command("echo")
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.EqualValues(t, "vi", name)
|
||||||
|
assert.EqualValues(t, "file/with space", args[0])
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
func(env string) string {
|
||||||
|
return ""
|
||||||
|
},
|
||||||
|
func(cf string) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
},
|
||||||
|
func(cmd *exec.Cmd, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user