aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-04 20:29:51 +0800
committerGitHub <noreply@github.com>2023-12-04 20:29:51 +0800
commit66f1563c7a48d76f99c89e32de030e57af2abfb4 (patch)
treee3c0966099e6cb2f3a631bca17259cc1d394d3fa /src/nvim/api/vim.c
parentcf612c64b0fc87c399bc5c72735335c5e73d6de1 (diff)
downloadrneovim-66f1563c7a48d76f99c89e32de030e57af2abfb4.tar.gz
rneovim-66f1563c7a48d76f99c89e32de030e57af2abfb4.tar.bz2
rneovim-66f1563c7a48d76f99c89e32de030e57af2abfb4.zip
refactor(terminal): only remove const qualifier when necessary (#26386)
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 270f2e4432..db08cb8cf0 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1017,18 +1017,19 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err)
}
}
- TerminalOptions topts;
Channel *chan = channel_alloc(kChannelStreamInternal);
chan->stream.internal.cb = cb;
chan->stream.internal.closed = false;
- topts.data = chan;
- // NB: overridden in terminal_check_size if a window is already
- // displaying the buffer
- topts.width = (uint16_t)MAX(curwin->w_width_inner - win_col_off(curwin), 0);
- topts.height = (uint16_t)curwin->w_height_inner;
- topts.write_cb = term_write;
- topts.resize_cb = term_resize;
- topts.close_cb = term_close;
+ TerminalOptions topts = {
+ .data = chan,
+ // NB: overridden in terminal_check_size if a window is already
+ // displaying the buffer
+ .width = (uint16_t)MAX(curwin->w_width_inner - win_col_off(curwin), 0),
+ .height = (uint16_t)curwin->w_height_inner,
+ .write_cb = term_write,
+ .resize_cb = term_resize,
+ .close_cb = term_close,
+ };
channel_incref(chan);
terminal_open(&chan->term, buf, topts);
if (chan->term != NULL) {
@@ -1038,7 +1039,7 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err)
return (Integer)chan->id;
}
-static void term_write(char *buf, size_t size, void *data) // NOLINT(readability-non-const-parameter)
+static void term_write(const char *buf, size_t size, void *data)
{
Channel *chan = data;
LuaRef cb = chan->stream.internal.cb;
@@ -1048,7 +1049,7 @@ static void term_write(char *buf, size_t size, void *data) // NOLINT(readabilit
MAXSIZE_TEMP_ARRAY(args, 3);
ADD_C(args, INTEGER_OBJ((Integer)chan->id));
ADD_C(args, BUFFER_OBJ(terminal_buf(chan->term)));
- ADD_C(args, STRING_OBJ(((String){ .data = buf, .size = size })));
+ ADD_C(args, STRING_OBJ(((String){ .data = (char *)buf, .size = size })));
textlock++;
nlua_call_ref(cb, "input", args, false, NULL);
textlock--;