diff options
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 55 |
1 files changed, 41 insertions, 14 deletions
@@ -843,7 +843,12 @@ doESCkey: if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C) ins_apply_autocmds(EVENT_INSERTLEAVE); did_cursorhold = FALSE; - curbuf->b_last_changedtick = CHANGEDTICK(curbuf); + + // ins_redraw() triggers TextChangedI only when no characters + // are in the typeahead buffer, so only reset curbuf->b_last_changedtick + // if the TextChangedI was not blocked by char_avail() (e.g. using :norm!) + if (!char_avail()) + curbuf->b_last_changedtick = CHANGEDTICK(curbuf); return (c == Ctrl_O); } continue; @@ -2023,7 +2028,7 @@ insert_special( * Only use mod_mask for special keys, to avoid things like <S-Space>, * unless 'allow_modmask' is TRUE. */ -#ifdef MACOS_X +#if defined(MACOS_X) || defined(FEAT_GUI_GTK) // Command-key never produces a normal key if (mod_mask & MOD_MASK_CMD) allow_modmask = TRUE; @@ -3217,7 +3222,7 @@ replace_do_bs(int limit_col) { // Do not adjust text properties for individual delete and insert // operations, do it afterwards on the resulting text. - len_before = STRLEN(ml_get_curline()); + len_before = ml_get_curline_len(); ++text_prop_frozen; } #endif @@ -3232,14 +3237,14 @@ replace_do_bs(int limit_col) { (void)del_char_after_col(limit_col); if (State & VREPLACE_FLAG) - orig_len = (int)STRLEN(ml_get_cursor()); + orig_len = ml_get_cursor_len(); replace_push(cc); } else { pchar_cursor(cc); if (State & VREPLACE_FLAG) - orig_len = (int)STRLEN(ml_get_cursor()) - 1; + orig_len = ml_get_cursor_len() - 1; } replace_pop_ins(); @@ -3247,7 +3252,7 @@ replace_do_bs(int limit_col) { // Get the number of screen cells used by the inserted characters p = ml_get_cursor(); - ins_len = (int)STRLEN(p) - orig_len; + ins_len = ml_get_cursor_len() - orig_len; vcol = start_vcol; for (i = 0; i < ins_len; ++i) { @@ -3273,7 +3278,7 @@ replace_do_bs(int limit_col) #ifdef FEAT_PROP_POPUP if (curbuf->b_has_textprop) { - size_t len_now = STRLEN(ml_get_curline()); + size_t len_now = ml_get_curline_len(); --text_prop_frozen; adjust_prop_columns(curwin->w_cursor.lnum, curwin->w_cursor.col, @@ -4063,7 +4068,7 @@ ins_bs( (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL) return FALSE; --Insstart.lnum; - Insstart.col = (colnr_T)STRLEN(ml_get(Insstart.lnum)); + Insstart.col = ml_get_len(Insstart.lnum); } /* * In replace mode: @@ -4096,12 +4101,30 @@ ins_bs( && has_format_option(FO_WHITE_PAR)) { char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, - TRUE); - int len; + FALSE); + int len = ml_get_curline_len(); - len = (int)STRLEN(ptr); if (len > 0 && ptr[len - 1] == ' ') - ptr[len - 1] = NUL; + { + char_u *newp = alloc(curbuf->b_ml.ml_line_len - 1); + + if (newp != NULL) + { + mch_memmove(newp, ptr, len - 1); + newp[len - 1] = NUL; + if (curbuf->b_ml.ml_line_len > len + 1) + mch_memmove(newp + len, ptr + len + 1, + curbuf->b_ml.ml_line_len - len - 1); + + if (curbuf->b_ml.ml_flags + & (ML_LINE_DIRTY | ML_ALLOCATED)) + vim_free(curbuf->b_ml.ml_line_ptr); + curbuf->b_ml.ml_line_ptr = newp; + curbuf->b_ml.ml_line_len--; + curbuf->b_ml.ml_line_textlen--; + curbuf->b_ml.ml_flags |= ML_LINE_DIRTY; + } + } } (void)do_join(2, FALSE, FALSE, FALSE, FALSE); @@ -4954,7 +4977,7 @@ ins_tab(void) { pos = curwin->w_cursor; cursor = &pos; - saved_line = vim_strsave(ml_get_curline()); + saved_line = vim_strnsave(ml_get_curline(), ml_get_curline_len()); if (saved_line == NULL) return FALSE; ptr = saved_line + pos.col; @@ -5065,6 +5088,7 @@ ins_tab(void) vim_free(curbuf->b_ml.ml_line_ptr); curbuf->b_ml.ml_line_ptr = newp; curbuf->b_ml.ml_line_len -= i; + curbuf->b_ml.ml_line_textlen = 0; curbuf->b_ml.ml_flags = (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY; } @@ -5150,7 +5174,7 @@ ins_eol(int c) // NL in reverse insert will always start in the end of // current line. if (revins_on) - curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor()); + curwin->w_cursor.col += ml_get_cursor_len(); #endif AppendToRedobuff(NL_STR); @@ -5371,6 +5395,9 @@ do_insert_char_pre(int c) if (!has_insertcharpre()) return NULL; + if (c == Ctrl_RSB) + return NULL; + if (has_mbyte) buf[(*mb_char2bytes)(c, buf)] = NUL; else |