diff options
author | Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.com> | 2017-06-10 09:00:15 +0100 |
---|---|---|
committer | Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.com> | 2017-06-10 09:00:15 +0100 |
commit | 2c236fc67be22bceea87fd1ee1e2db5a9d3941c0 (patch) | |
tree | ee8928bd1b9559eeaa153f344fecfb0c42abaca5 | |
parent | cdfaecb25f6a9a94f29a38d9f2d24a579b3dff5f (diff) | |
download | rneovim-2c236fc67be22bceea87fd1ee1e2db5a9d3941c0.tar.gz rneovim-2c236fc67be22bceea87fd1ee1e2db5a9d3941c0.tar.bz2 rneovim-2c236fc67be22bceea87fd1ee1e2db5a9d3941c0.zip |
tui: Track cursor visibility.
This fixes a test failure caused by dfaecb25f6a9a94f29a38d9f2d24a579b3dff5f
not tracking what the current visibility is and whether it matches the
current business state.
-rw-r--r-- | src/nvim/tui/tui.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 931f2738ab..a85f119ef4 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -96,7 +96,7 @@ typedef struct { bool can_set_left_right_margin; bool immediate_wrap_after_last_column; bool mouse_enabled; - bool busy; + bool busy, is_invisible; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; HlAttrs print_attrs; bool default_attr; @@ -173,6 +173,8 @@ static void terminfo_start(UI *ui) data->scroll_region_is_full_screen = true; data->bufpos = 0; data->default_attr = false; + data->is_invisible = true; + data->busy = false; data->showing_mode = SHAPE_IDX_N; data->unibi_ext.enable_mouse = -1; data->unibi_ext.disable_mouse = -1; @@ -1630,28 +1632,32 @@ static void flush_buf(UI *ui, bool toggle_cursor) uv_buf_t *bufp = bufs; TUIData *data = ui->data; - if (data->bufpos <= 0) { + if (data->bufpos <= 0 && data->busy == data->is_invisible) { return; } - if (toggle_cursor && !data->busy) { - // not busy and cursor is visible, write a "cursor invisible" command - // before writing the buffer. + if (toggle_cursor && !data->is_invisible) { + // cursor is visible. Write a "cursor invisible" command before writing the + // buffer. bufp->base = data->invis; bufp->len = data->invislen; bufp++; + data->is_invisible = true; } - bufp->base = data->buf; - bufp->len = data->bufpos; - bufp++; + if (data->bufpos > 0) { + bufp->base = data->buf; + bufp->len = data->bufpos; + bufp++; + } - if (toggle_cursor && !data->busy) { + if (toggle_cursor && !data->busy && data->is_invisible) { // not busy and the cursor is invisible. Write a "cursor normal" command // after writing the buffer. bufp->base = data->norm; bufp->len = data->normlen; bufp++; + data->is_invisible = data->busy; } uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), bufs, (unsigned)(bufp - bufs), NULL); |