aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/highlight.c10
-rw-r--r--src/nvim/mbyte.c8
-rw-r--r--src/nvim/move.c4
-rw-r--r--src/nvim/screen.c33
-rw-r--r--src/nvim/window.c2
6 files changed, 33 insertions, 26 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 4399e118f0..eb81ee9320 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1494,7 +1494,7 @@ void edit_putchar(int c, int highlight)
{
int attr;
- if (default_grid.ScreenLines != NULL) {
+ if (curwin->w_grid.ScreenLines != NULL || default_grid.ScreenLines != NULL) {
update_topline(); // just in case w_topline isn't valid
validate_cursor();
if (highlight) {
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index cbc230b65a..41d60fa3ea 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -98,7 +98,7 @@ static int get_attr_entry(HlEntry entry)
return id;
}
-/// When a UI connects, we need to send it the table of higlights used so far.
+/// When a UI connects, we need to send it the table of highlights used so far.
void ui_send_all_hls(UI *ui)
{
for (size_t i = 1; i < kv_size(attr_entries); i++) {
@@ -212,13 +212,7 @@ void clear_hl_tables(bool reinit)
map_clear(int, int)(combine_attr_entries);
highlight_attr_set_all();
highlight_changed();
- redraw_all_later(NOT_VALID);
- if (default_grid.ScreenAttrs) {
- // the meaning of 0 doesn't change anyway
- // but the rest must be retransmitted
- memset(default_grid.ScreenAttrs, 0, sizeof(*default_grid.ScreenAttrs)
- * (size_t)(default_grid.Rows * default_grid.Columns));
- }
+ screen_invalidate_highlights();
} else {
kv_destroy(attr_entries);
map_free(HlEntry, int)(attr_entry_ids);
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 73748154e7..ead6b4405d 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -556,14 +556,6 @@ size_t mb_string2cells(const char_u *str)
return clen;
}
-/// Return number of display cells for char at ScreenLines[off].
-/// We make sure that the offset used is less than "max_off".
-int utf_off2cells(ScreenGrid *grid, unsigned off, unsigned max_off)
-{
- return (off + 1 < max_off
- && grid->ScreenLines[off + 1][0] == 0) ? 2 : 1;
-}
-
/// Convert a UTF-8 byte sequence to a wide character
///
/// If the sequence is illegal or truncated by a NUL then the first byte is
diff --git a/src/nvim/move.c b/src/nvim/move.c
index ebbcd1b853..b8225cc64c 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -151,7 +151,7 @@ void update_topline(void)
long save_so = p_so;
// need to have w_grid.Rows/Columns updated
- win_grid_alloc(curwin, false);
+ win_grid_alloc(curwin);
// If there is no valid screen and when the window height is zero just use
// the cursor line.
@@ -529,7 +529,7 @@ int cursor_valid(void)
*/
void validate_cursor(void)
{
- win_grid_alloc(curwin, false); // we need to have w_grid.Rows/Columns updated
+ win_grid_alloc(curwin); // we need to have w_grid.Rows/Columns updated
check_cursor_moved(curwin);
if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW))
curs_columns(true);
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index c088367c69..079ed049e4 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -146,7 +146,10 @@ typedef struct {
#define LINE_STATE(p) { p, 0, 0 }
/// Whether to call "ui_call_grid_resize" in win_grid_alloc
-static int send_grid_resize;
+static bool send_grid_resize = false;
+
+/// Highlight ids are no longer valid. Force retransmission
+static bool highlights_invalid = false;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "screen.c.generated.h"
@@ -184,6 +187,12 @@ void redraw_all_later(int type)
}
}
+void screen_invalidate_highlights(void)
+{
+ redraw_all_later(NOT_VALID);
+ highlights_invalid = true;
+}
+
/*
* Mark all windows that are editing the current buffer to be updated later.
*/
@@ -353,6 +362,8 @@ void update_screen(int type)
type = NOT_VALID;
// must_redraw may be set indirectly, avoid another redraw later
must_redraw = 0;
+ } else if (highlights_invalid) {
+ grid_invalidate(&default_grid);
}
if (clear_cmdline) /* going to clear cmdline (done below) */
@@ -439,6 +450,7 @@ void update_screen(int type)
}
}
send_grid_resize = false;
+ highlights_invalid = false;
end_search_hl();
// May need to redraw the popup menu.
if (pum_drawn()) {
@@ -522,7 +534,7 @@ void update_single_line(win_T *wp, linenr_T lnum)
prepare_search_hl(wp, lnum);
update_window_hl(wp, false);
// allocate window grid if not already
- win_grid_alloc(wp, false);
+ win_grid_alloc(wp);
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, false, false);
end_search_hl();
break;
@@ -680,7 +692,7 @@ static void win_update(win_T *wp)
type = wp->w_redr_type;
- win_grid_alloc(wp, false);
+ win_grid_alloc(wp);
if (type >= NOT_VALID) {
wp->w_redr_status = true;
@@ -5984,7 +5996,7 @@ int screen_valid(int doclear)
///
/// If "doclear" is true, don't try to copy from the old grid rather clear the
/// resized grid.
-void win_grid_alloc(win_T *wp, int doclear)
+void win_grid_alloc(win_T *wp)
{
ScreenGrid *grid = &wp->w_grid;
int rows = grid->internal_rows;
@@ -6002,11 +6014,15 @@ void win_grid_alloc(win_T *wp, int doclear)
bool want_allocation = ui_is_external(kUIMultigrid);
bool has_allocation = (grid->ScreenLines != NULL);
+ if (want_allocation && has_allocation && highlights_invalid) {
+ grid_invalidate(grid);
+ }
+
if ((has_allocation != want_allocation)
|| grid->Rows != rows
|| grid->Columns != columns) {
if (want_allocation) {
- grid_alloc(grid, rows, columns, !doclear);
+ grid_alloc(grid, rows, columns, true);
win_free_lsize(wp);
win_alloc_lines(wp);
} else {
@@ -6289,6 +6305,13 @@ static void grid_clear_line(ScreenGrid *grid, unsigned off, int width,
(void)memset(grid->ScreenAttrs + off, fill, (size_t)width * sizeof(sattr_T));
}
+static void grid_invalidate(ScreenGrid *grid)
+{
+ (void)memset(grid->ScreenAttrs, -1,
+ grid->Rows * grid->Columns * sizeof(sattr_T));
+}
+
+
/// Copy part of a Screenline for vertically split window.
static void linecopy(ScreenGrid *grid, int to, int from, int col, int width)
{
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 39fc1897ae..7e381e7069 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4299,7 +4299,6 @@ void win_setheight_win(int height, win_T *win)
}
frame_setheight(win->w_frame, height + win->w_status_height);
- win_grid_alloc(win, false);
/* recompute the window positions */
row = win_comp_pos();
@@ -4497,7 +4496,6 @@ void win_setwidth_win(int width, win_T *wp)
}
frame_setwidth(wp->w_frame, width + wp->w_vsep_width);
- win_grid_alloc(wp, false);
/* recompute the window positions */
(void)win_comp_pos();