mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 23:08:16 +00:00
fix(termopen): avoid ambiguity in URI when CWD is root dir (#16988)
This commit is contained in:
@@ -10790,10 +10790,16 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
// "/home/foo/…" => "~/…"
|
||||
size_t len = home_replace(NULL, NameBuff, IObuff, sizeof(IObuff), true);
|
||||
// Trim slash.
|
||||
if (IObuff[len - 1] == '\\' || IObuff[len - 1] == '/') {
|
||||
if (len != 1 && (IObuff[len - 1] == '\\' || IObuff[len - 1] == '/')) {
|
||||
IObuff[len - 1] = '\0';
|
||||
}
|
||||
|
||||
if (len == 1 && IObuff[0] == '/') {
|
||||
// Avoid ambiguity in the URI when CWD is root directory.
|
||||
IObuff[1] = '.';
|
||||
IObuff[2] = '\0';
|
||||
}
|
||||
|
||||
// Terminal URI: "term://$CWD//$PID:$CMD"
|
||||
snprintf((char *)NameBuff, sizeof(NameBuff), "term://%s//%d:%s",
|
||||
(char *)IObuff, pid, cmd);
|
||||
|
Reference in New Issue
Block a user