mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 00:08:19 +00:00
main.c: "BufReadCmd term://": Skip existing terminal.
Check `exists('b:term_title')` to avoid the BufReadCmd for already-initialized :terminal buffers. Move the test for `:argadd`. Add a test for `:edit<CR>`. Tweak comments and code style.
This commit is contained in:
@@ -320,14 +320,18 @@ int main(int argc, char **argv)
|
||||
|
||||
// open terminals when opening files that start with term://
|
||||
#define PROTO "term://"
|
||||
do_cmdline_cmd("augroup nvim_terminal");
|
||||
do_cmdline_cmd("autocmd!");
|
||||
do_cmdline_cmd("autocmd BufReadCmd " PROTO "* nested "
|
||||
":call termopen( "
|
||||
":if !exists('b:term_title')|call termopen( "
|
||||
// Capture the command string
|
||||
"matchstr(expand(\"<amatch>\"), "
|
||||
"'\\c\\m" PROTO "\\%(.\\{-}//\\%(\\d\\+:\\)\\?\\)\\?\\zs.*'), "
|
||||
// capture the working directory
|
||||
"{'cwd': get(matchlist(expand(\"<amatch>\"), "
|
||||
"'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, '')})");
|
||||
"'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, '')})"
|
||||
"|endif");
|
||||
do_cmdline_cmd("augroup END");
|
||||
#undef PROTO
|
||||
|
||||
/* Execute --cmd arguments. */
|
||||
|
Reference in New Issue
Block a user