nsmarks: initial commit

This commit is contained in:
timeyyy
2017-01-18 13:20:07 +01:00
committed by Björn Linse
parent e757f4d536
commit a9065a5051
27 changed files with 3968 additions and 81 deletions

View File

@@ -28,6 +28,7 @@
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/main.h"
#include "nvim/mark_extended.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
@@ -1837,6 +1838,13 @@ change_indent (
xfree(new_line);
}
// change_indent seems to bec called twice, this combination only triggers
// once for both calls
if (new_cursor_col - vcol != 0) {
extmark_col_adjust(curbuf, curwin->w_cursor.lnum, 0, 0, amount,
kExtmarkUndo);
}
}
/*
@@ -5587,6 +5595,9 @@ insertchar (
do_digraph(buf[i-1]); /* may be the start of a digraph */
buf[i] = NUL;
ins_str(buf);
extmark_col_adjust(curbuf, curwin->w_cursor.lnum,
(colnr_T)(curwin->w_cursor.col + 1), 0,
(long)STRLEN(buf), kExtmarkUndo);
if (flags & INSCHAR_CTRLV) {
redo_literal(*buf);
i = 1;
@@ -5597,6 +5608,9 @@ insertchar (
} else {
int cc;
extmark_col_adjust(curbuf, curwin->w_cursor.lnum,
(colnr_T)(curwin->w_cursor.col + 1), 0,
1, kExtmarkUndo);
if ((cc = utf_char2len(c)) > 1) {
char_u buf[MB_MAXBYTES + 1];
@@ -5606,10 +5620,11 @@ insertchar (
AppendCharToRedobuff(c);
} else {
ins_char(c);
if (flags & INSCHAR_CTRLV)
if (flags & INSCHAR_CTRLV) {
redo_literal(c);
else
} else {
AppendCharToRedobuff(c);
}
}
}
}
@@ -6891,8 +6906,9 @@ static void mb_replace_pop_ins(int cc)
for (i = 1; i < n; ++i)
buf[i] = replace_pop();
ins_bytes_len(buf, n);
} else
} else {
ins_char(cc);
}
if (enc_utf8)
/* Handle composing chars. */
@@ -8002,9 +8018,9 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
Insstart_orig.col = curwin->w_cursor.col;
}
if (State & VREPLACE_FLAG)
if (State & VREPLACE_FLAG) {
ins_char(' ');
else {
} else {
ins_str((char_u *)" ");
if ((State & REPLACE_FLAG))
replace_push(NUL);
@@ -8482,8 +8498,17 @@ static bool ins_tab(void)
} else { // otherwise use "tabstop"
temp = (int)curbuf->b_p_ts;
}
temp -= get_nolist_virtcol() % temp;
// Move extmarks
extmark_col_adjust(curbuf,
curwin->w_cursor.lnum,
curwin->w_cursor.col,
0,
temp,
kExtmarkUndo);
/*
* Insert the first space with ins_char(). It will delete one char in
* replace mode. Insert the rest with ins_str(); it will not delete any
@@ -8491,12 +8516,13 @@ static bool ins_tab(void)
*/
ins_char(' ');
while (--temp > 0) {
if (State & VREPLACE_FLAG)
if (State & VREPLACE_FLAG) {
ins_char(' ');
else {
} else {
ins_str((char_u *)" ");
if (State & REPLACE_FLAG) /* no char replaced */
if (State & REPLACE_FLAG) { // no char replaced
replace_push(NUL);
}
}
}