aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/keysets.h1
-rw-r--r--src/nvim/api/vim.c1
-rw-r--r--src/nvim/buffer.c1
-rw-r--r--src/nvim/buffer_defs.h6
-rw-r--r--src/nvim/bufwrite.c4
-rw-r--r--src/nvim/drawline.c33
-rw-r--r--src/nvim/edit.c16
-rw-r--r--src/nvim/highlight_group.c3
8 files changed, 41 insertions, 24 deletions
diff --git a/src/nvim/api/keysets.h b/src/nvim/api/keysets.h
index 736ca9ce07..236e75983e 100644
--- a/src/nvim/api/keysets.h
+++ b/src/nvim/api/keysets.h
@@ -169,6 +169,7 @@ typedef struct {
Integer blend;
Boolean fg_indexed;
Boolean bg_indexed;
+ Boolean force;
} Dict(highlight);
typedef struct {
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 78396edef5..00641c633d 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -151,6 +151,7 @@ Dictionary nvim_get_hl(Integer ns_id, Dict(get_highlight) *opts, Arena *arena, E
/// - cterm: cterm attribute map, like |highlight-args|. If not set,
/// cterm attributes will match those from the attribute map
/// documented above.
+/// - force: if true force update the highlight group when it exists.
/// @param[out] err Error details, if any
///
// TODO(bfredl): val should take update vs reset flag
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 7a3e65e10e..15fbf7df7b 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -354,6 +354,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg)
// Set last_changedtick to avoid triggering a TextChanged autocommand right
// after it was added.
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
+ curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf);
curbuf->b_last_changedtick_pum = buf_get_changedtick(curbuf);
// require "!" to overwrite the file, because it wasn't read completely
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index ff0fca1a56..f267dbb2f1 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -418,10 +418,10 @@ struct file_buffer {
/// This is a dictionary item used to store b:changedtick.
ChangedtickDictItem changedtick_di;
- varnumber_T b_last_changedtick; // b:changedtick when TextChanged or
- // TextChangedI was last triggered.
- varnumber_T b_last_changedtick_pum; // b:changedtick when TextChangedP was
+ varnumber_T b_last_changedtick; // b:changedtick when TextChanged was
// last triggered.
+ varnumber_T b_last_changedtick_i; // b:changedtick for TextChangedI
+ varnumber_T b_last_changedtick_pum; // b:changedtick for TextChangedP
bool b_saving; // Set to true if we are in the middle of
// saving the buffer.
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c
index 0c95314c52..2f13586dcc 100644
--- a/src/nvim/bufwrite.c
+++ b/src/nvim/bufwrite.c
@@ -1797,8 +1797,8 @@ restore_backup:
unchanged(buf, true, false);
const varnumber_T changedtick = buf_get_changedtick(buf);
if (buf->b_last_changedtick + 1 == changedtick) {
- // b:changedtick may be incremented in unchanged() but that
- // should not trigger a TextChanged event.
+ // b:changedtick may be incremented in unchanged() but that should not
+ // trigger a TextChanged event.
buf->b_last_changedtick = changedtick;
}
u_unchanged(buf);
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 1e5798db32..9da421e79b 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -207,6 +207,16 @@ static void margin_columns_win(win_T *wp, int *left_col, int *right_col)
prev_col_off = cur_col_off;
}
+/// If one half of a double-width char will be overwritten,
+/// change the other half to a space so that grid redraws properly.
+static void line_check_overwrite(schar_T *dest, int cells, int maxcells, bool rl)
+{
+ assert(cells > 0);
+ if (cells < maxcells && dest[rl ? -cells + 1 : cells] == 0) {
+ dest[rl ? -cells : cells] = schar_from_ascii(' ');
+ }
+}
+
/// Put a single char from an UTF-8 buffer into a line buffer.
///
/// Handles composing chars and arabic shaping state.
@@ -216,12 +226,17 @@ static int line_putchar(buf_T *buf, LineState *s, schar_T *dest, int maxcells, b
int cells = utf_ptr2cells(p);
int c_len = utfc_ptr2len(p);
int u8c, u8cc[MAX_MCO];
+ assert(maxcells > 0);
if (cells > maxcells) {
return -1;
}
u8c = utfc_ptr2char(p, u8cc);
if (*p == TAB) {
cells = MIN(tabstop_padding(vcol, buf->b_p_ts, buf->b_p_vts_array), maxcells);
+ }
+
+ line_check_overwrite(dest, cells, maxcells, rl);
+ if (*p == TAB) {
for (int c = 0; c < cells; c++) {
dest[rl ? -c : c] = schar_from_ascii(' ');
}
@@ -304,8 +319,9 @@ static void draw_virt_text(win_T *wp, buf_T *buf, int col_off, int *end_col, int
kv_push(win_extmark_arr, m);
}
if (kv_size(item->decor.virt_text)) {
+ int vcol = wp->w_p_rl ? col_off - item->draw_col : item->draw_col - col_off;
col = draw_virt_text_item(buf, item->draw_col, item->decor.virt_text,
- item->decor.hl_mode, max_col, item->draw_col - col_off, wp->w_p_rl);
+ item->decor.hl_mode, max_col, vcol, wp->w_p_rl);
}
item->draw_col = INT_MIN; // deactivate
if (item->decor.virt_text_pos == kVTEndOfLine && do_eol) {
@@ -356,13 +372,15 @@ static int draw_virt_text_item(buf_T *buf, int col, VirtText vt, HlMode hl_mode,
attr = virt_attr;
}
schar_T dummy[2];
- bool rl_overwrote_double_width = linebuf_char[col] == 0;
+ int maxcells = rl ? col - max_col : max_col - col;
int cells = line_putchar(buf, &s, through ? dummy : &linebuf_char[col],
- rl ? col - max_col : max_col - col, rl, vcol);
+ maxcells, rl, vcol);
// If we failed to emit a char, we still need to put a space and advance.
if (cells < 1) {
- linebuf_char[col] = schar_from_ascii(' ');
+ assert(!through);
cells = 1;
+ line_check_overwrite(&linebuf_char[col], cells, maxcells, rl);
+ linebuf_char[col] = schar_from_ascii(' ');
}
for (int c = 0; c < cells; c++) {
linebuf_attr[col] = attr;
@@ -372,13 +390,6 @@ static int draw_virt_text_item(buf_T *buf, int col, VirtText vt, HlMode hl_mode,
col++;
}
}
- // If one half of a double-width char is overwritten,
- // change the other half to a space so that grid redraws properly,
- // but don't advance the current column.
- if ((rl && col > max_col && rl_overwrote_double_width)
- || (!rl && col < max_col && linebuf_char[col] == 0)) {
- linebuf_char[col] = schar_from_ascii(' ');
- }
vcol += cells;
}
return col;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 520d3bc2b3..8def1bf35d 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -878,6 +878,10 @@ static int insert_handle_key(InsertState *s)
case K_EVENT: // some event
state_handle_k_event();
+ // If CTRL-G U was used apply it to the next typed key.
+ if (dont_sync_undo == kTrue) {
+ dont_sync_undo = kNone;
+ }
goto check_pum;
case K_COMMAND: // <Cmd>command<CR>
@@ -1306,9 +1310,9 @@ void ins_redraw(bool ready)
last_cursormoved = curwin->w_cursor;
}
- // Trigger TextChangedI if changedtick differs.
+ // Trigger TextChangedI if changedtick_i differs.
if (ready && has_event(EVENT_TEXTCHANGEDI)
- && curbuf->b_last_changedtick != buf_get_changedtick(curbuf)
+ && curbuf->b_last_changedtick_i != buf_get_changedtick(curbuf)
&& !pum_visible()) {
aco_save_T aco;
varnumber_T tick = buf_get_changedtick(curbuf);
@@ -1317,16 +1321,16 @@ void ins_redraw(bool ready)
aucmd_prepbuf(&aco, curbuf);
apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, false, curbuf);
aucmd_restbuf(&aco);
- curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
+ curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf);
if (tick != buf_get_changedtick(curbuf)) { // see ins_apply_autocmds()
u_save(curwin->w_cursor.lnum,
(linenr_T)(curwin->w_cursor.lnum + 1));
}
}
- // Trigger TextChangedP if changedtick differs. When the popupmenu closes
- // TextChangedI will need to trigger for backwards compatibility, thus use
- // different b_last_changedtick* variables.
+ // Trigger TextChangedP if changedtick_pum differs. When the popupmenu
+ // closes TextChangedI will need to trigger for backwards compatibility,
+ // thus use different b_last_changedtick* variables.
if (ready && has_event(EVENT_TEXTCHANGEDP)
&& curbuf->b_last_changedtick_pum != buf_get_changedtick(curbuf)
&& pum_visible()) {
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 84cf19ba69..eeed58a9ab 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -799,11 +799,10 @@ int lookup_color(const int idx, const bool foreground, TriState *const boldp)
void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
{
int idx = id - 1; // Index is ID minus one.
-
bool is_default = attrs.rgb_ae_attr & HL_DEFAULT;
// Return if "default" was used and the group already has settings
- if (is_default && hl_has_settings(idx, true)) {
+ if (is_default && hl_has_settings(idx, true) && !dict->force) {
return;
}