diff options
author | Ricky Zhou <rickyz@google.com> | 2023-06-01 02:15:14 -0700 |
---|---|---|
committer | Ricky Zhou <rickyz@google.com> | 2023-06-05 22:34:55 -0700 |
commit | 981acc2922ce9a5f214ba14acbb1e444748855f2 (patch) | |
tree | 6316a11d19f9f63adf7ffd6dbc585600c7b36c45 /src/nvim/api/ui.c | |
parent | 780ab11b90119fb9b91d3266d6eef459228edc9a (diff) | |
download | rneovim-981acc2922ce9a5f214ba14acbb1e444748855f2.tar.gz rneovim-981acc2922ce9a5f214ba14acbb1e444748855f2.tar.bz2 rneovim-981acc2922ce9a5f214ba14acbb1e444748855f2.zip |
fix(ui): propagate line wrapping state on grid_line events
This fixes the TUI's line-wrapping behavior, which was broken with the
migration to the msgpack-based UI protocol (see
https://github.com/neovim/neovim/issues/7369#issuecomment-1571812273).
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r-- | src/nvim/api/ui.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index e98c589189..861ce100cd 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -73,6 +73,11 @@ static void mpack_uint(char **buf, uint32_t val) } } +static void mpack_bool(char **buf, bool val) +{ + mpack_w(buf, 0xc2 | val); +} + static void mpack_array(char **buf, uint32_t len) { if (len < 0x10) { @@ -809,7 +814,7 @@ void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Int data->ncalls++; char **buf = &data->buf_wptr; - mpack_array(buf, 4); + mpack_array(buf, 5); mpack_uint(buf, (uint32_t)grid); mpack_uint(buf, (uint32_t)row); mpack_uint(buf, (uint32_t)startcol); @@ -823,17 +828,20 @@ void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Int repeat++; if (i == ncells - 1 || attrs[i] != attrs[i + 1] || strcmp(chunk[i], chunk[i + 1]) != 0) { - if (UI_BUF_SIZE - BUF_POS(data) < 2 * (1 + 2 + sizeof(schar_T) + 5 + 5)) { + if (UI_BUF_SIZE - BUF_POS(data) < 2 * (1 + 2 + sizeof(schar_T) + 5 + 5) + 1) { // close to overflowing the redraw buffer. finish this event, // flush, and start a new "grid_line" event at the current position. // For simplicity leave place for the final "clear" element // as well, hence the factor of 2 in the check. mpack_w2(&lenpos, nelem); + + // We only ever set the wrap field on the final "grid_line" event for the line. + mpack_bool(buf, false); remote_ui_flush_buf(ui); prepare_call(ui, "grid_line"); data->ncalls++; - mpack_array(buf, 4); + mpack_array(buf, 5); mpack_uint(buf, (uint32_t)grid); mpack_uint(buf, (uint32_t)row); mpack_uint(buf, (uint32_t)startcol + (uint32_t)i - repeat + 1); @@ -865,9 +873,10 @@ void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Int mpack_uint(buf, (uint32_t)(clearcol - endcol)); } mpack_w2(&lenpos, nelem); + mpack_bool(buf, flags & kLineFlagWrap); if (data->ncells_pending > 500) { - // pass of cells to UI to let it start processing them + // pass off cells to UI to let it start processing them remote_ui_flush_buf(ui); } } else { |