diff options
author | Raphael <glephunter@gmail.com> | 2023-12-14 16:08:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 16:08:00 +0800 |
commit | 619407eb548c7df56bc99b945338e9446f846fbb (patch) | |
tree | 7e3b4e11f467c32de90cdc1afa7de08cc725c4e7 /src/nvim/api | |
parent | 36552adb39edff2d909743f16c1f061bc74b5c4e (diff) | |
download | rneovim-619407eb548c7df56bc99b945338e9446f846fbb.tar.gz rneovim-619407eb548c7df56bc99b945338e9446f846fbb.tar.bz2 rneovim-619407eb548c7df56bc99b945338e9446f846fbb.zip |
feat(nvim_open_term): convert LF => CRLF (#26384)
Problem:
Unlike termopen(), nvim_open_term() PTYs do not carriage-return the
cursor on newline ("\n") input.
nvim --clean
:let chan_id = nvim_open_term(1, {})
:call chansend(chan_id, ["here", "are", "some", "lines"])
Actual behavior:
here
are
some
lines
Expected behaviour:
here
are
some
lines
Solution:
Add `force_crlf` option, and enable it by default.
Diffstat (limited to 'src/nvim/api')
-rw-r--r-- | src/nvim/api/keysets_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h index d1cbe43de0..c0daa0ca74 100644 --- a/src/nvim/api/keysets_defs.h +++ b/src/nvim/api/keysets_defs.h @@ -344,4 +344,5 @@ typedef struct { typedef struct { OptionalKeys is_set__open_term_; LuaRef on_input; + Boolean force_crlf; } Dict(open_term); diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index a52d7493e3..2f3d527b9e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -985,6 +985,7 @@ fail: /// as a "\r", not as a "\n". |textlock| applies. It is possible /// to call |nvim_chan_send()| directly in the callback however. /// ["input", term, bufnr, data] +/// - force_crlf: (boolean, default true) Convert "\n" to "\r\n". /// @param[out] err Error details, if any /// @return Channel id, or 0 on error Integer nvim_open_term(Buffer buffer, Dict(open_term) *opts, Error *err) @@ -1002,7 +1003,6 @@ Integer nvim_open_term(Buffer buffer, Dict(open_term) *opts, Error *err) } LuaRef cb = LUA_NOREF; - if (HAS_KEY(opts, open_term, on_input)) { cb = opts->on_input; opts->on_input = LUA_NOREF; @@ -1020,6 +1020,7 @@ Integer nvim_open_term(Buffer buffer, Dict(open_term) *opts, Error *err) .write_cb = term_write, .resize_cb = term_resize, .close_cb = term_close, + .force_crlf = GET_BOOL_OR_TRUE(opts, open_term, force_crlf), }; channel_incref(chan); terminal_open(&chan->term, buf, topts); |