aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-10-25 09:59:02 +0800
committerGitHub <noreply@github.com>2023-10-25 09:59:02 +0800
commit684e93054b82c6b5b215db7d3ecbad803eb81f0e (patch)
tree4df579bfcad117e96b7546d5441c80cb62251280 /src/nvim/api/vim.c
parent1094d0c0dbd0f37ccc0f1d18c73c6066e5690664 (diff)
downloadrneovim-684e93054b82c6b5b215db7d3ecbad803eb81f0e.tar.gz
rneovim-684e93054b82c6b5b215db7d3ecbad803eb81f0e.tar.bz2
rneovim-684e93054b82c6b5b215db7d3ecbad803eb81f0e.zip
fix(terminal): assign channel to terminal earlier (#25771)
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 52022cba5d..c3c619e206 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1034,9 +1034,12 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err)
topts.write_cb = term_write;
topts.resize_cb = term_resize;
topts.close_cb = term_close;
- Terminal *term = terminal_open(buf, topts);
- terminal_check_size(term);
- chan->term = term;
+ channel_incref(chan);
+ terminal_open(&chan->term, buf, topts);
+ if (chan->term != NULL) {
+ terminal_check_size(chan->term);
+ }
+ channel_decref(chan);
return (Integer)chan->id;
}