diff options
author | Chris LaRose <cjlarose@gmail.com> | 2020-01-26 00:24:42 -0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2020-01-26 00:24:42 -0800 |
commit | c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f (patch) | |
tree | 0614f7241a3fccd0c708d541bdc9e5ab4e15afca /src | |
parent | 451af7f08779ba39d3ebef4b2295ba702cc4f3d7 (diff) | |
download | rneovim-c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f.tar.gz rneovim-c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f.tar.bz2 rneovim-c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f.zip |
terminal: absolute CWD in term:// URI #11289
This makes it possible to restore the working directory of :terminal
buffers when reading those buffers from a session file.
Fixes #11288
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 12 | ||||
-rw-r--r-- | src/nvim/main.c | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9379d94fa3..ce1d55afab 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -18383,13 +18383,17 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) int pid = chan->stream.pty.process.pid; - char buf[1024]; - // format the title with the pid to conform with the term:// URI - snprintf(buf, sizeof(buf), "term://%s//%d:%s", cwd, pid, cmd); + // "./…" => "/home/foo/…" + vim_FullName(cwd, (char *)NameBuff, sizeof(NameBuff), false); + // "/home/foo/…" => "~/…" + home_replace(NULL, NameBuff, IObuff, sizeof(IObuff), true); + // Terminal URI: "term://$CWD//$PID:$CMD" + snprintf((char *)NameBuff, sizeof(NameBuff), "term://%s//%d:%s", + (char *)IObuff, pid, cmd); // at this point the buffer has no terminal instance associated yet, so unset // the 'swapfile' option to ensure no swap file will be created curbuf->b_p_swf = false; - (void)setfname(curbuf, (char_u *)buf, NULL, true); + (void)setfname(curbuf, NameBuff, NULL, true); // Save the job id and pid in b:terminal_job_{id,pid} Error err = ERROR_INIT; // deprecated: use 'channel' buffer option diff --git a/src/nvim/main.c b/src/nvim/main.c index be279b449a..a816221a9e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -339,8 +339,8 @@ int main(int argc, char **argv) "matchstr(expand(\"<amatch>\"), " "'\\c\\m" PROTO "\\%(.\\{-}//\\%(\\d\\+:\\)\\?\\)\\?\\zs.*'), " // capture the working directory - "{'cwd': get(matchlist(expand(\"<amatch>\"), " - "'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, '')})" + "{'cwd': expand(get(matchlist(expand(\"<amatch>\"), " + "'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, ''))})" "|endif"); do_cmdline_cmd("augroup END"); #undef PROTO |