Merge pull request #10171 from blueyed/vim-8.1.1318

vim-patch:8.1.1318: code for text changes is in a "misc" file
This commit is contained in:
Daniel Hahler 2019-08-09 19:25:56 +02:00 committed by GitHub
commit e2d6e67bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1830 additions and 1846 deletions

View File

@ -15,6 +15,7 @@
#include "nvim/lua/executor.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/getchar.h"

View File

@ -32,6 +32,7 @@
#include "nvim/channel.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"

1798
src/nvim/change.c Normal file

File diff suppressed because it is too large Load Diff

11
src/nvim/change.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef NVIM_CHANGE_H
#define NVIM_CHANGE_H
#include "nvim/buffer_defs.h" // for buf_T
#include "nvim/pos.h" // for linenr_T
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "change.h.generated.h"
#endif
#endif // NVIM_CHANGE_H

View File

@ -5,6 +5,7 @@
#include <inttypes.h>
#include "nvim/assert.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/charset.h"
#include "nvim/fold.h"

View File

@ -18,6 +18,7 @@
#include "nvim/ascii.h"
#include "nvim/diff.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/eval.h"

View File

@ -14,6 +14,7 @@
#include "nvim/ascii.h"
#include "nvim/edit.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/digraph.h"

View File

@ -24,6 +24,7 @@
#endif
#include "nvim/eval.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/channel.h"
#include "nvim/charset.h"
#include "nvim/context.h"

View File

@ -20,6 +20,7 @@
#include "nvim/ascii.h"
#include "nvim/ex_cmds.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"

View File

@ -18,6 +18,7 @@
#endif
#include "nvim/ex_cmds2.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"

View File

@ -16,6 +16,7 @@
#include "nvim/ascii.h"
#include "nvim/ex_docmd.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"

View File

@ -15,6 +15,7 @@
#include "nvim/ascii.h"
#include "nvim/fileio.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"

View File

@ -13,6 +13,7 @@
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/fold.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"

View File

@ -7,6 +7,7 @@
#include "nvim/ascii.h"
#include "nvim/assert.h"
#include "nvim/change.h"
#include "nvim/indent.h"
#include "nvim/eval.h"
#include "nvim/charset.h"
@ -316,109 +317,6 @@ int set_indent(int size, int flags)
}
// Copy the indent from ptr to the current line (and fill to size).
// Leaves the cursor on the first non-blank in the line.
// @return true if the line was changed.
int copy_indent(int size, char_u *src)
{
char_u *p = NULL;
char_u *line = NULL;
char_u *s;
int todo;
int ind_len;
int line_len = 0;
int tab_pad;
int ind_done;
int round;
// Round 1: compute the number of characters needed for the indent
// Round 2: copy the characters.
for (round = 1; round <= 2; ++round) {
todo = size;
ind_len = 0;
ind_done = 0;
s = src;
// Count/copy the usable portion of the source line.
while (todo > 0 && ascii_iswhite(*s)) {
if (*s == TAB) {
tab_pad = (int)curbuf->b_p_ts
- (ind_done % (int)curbuf->b_p_ts);
// Stop if this tab will overshoot the target.
if (todo < tab_pad) {
break;
}
todo -= tab_pad;
ind_done += tab_pad;
} else {
todo--;
ind_done++;
}
ind_len++;
if (p != NULL) {
*p++ = *s;
}
s++;
}
// Fill to next tabstop with a tab, if possible.
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
if ((todo >= tab_pad) && !curbuf->b_p_et) {
todo -= tab_pad;
ind_len++;
if (p != NULL) {
*p++ = TAB;
}
}
// Add tabs required for indent.
while (todo >= (int)curbuf->b_p_ts && !curbuf->b_p_et) {
todo -= (int)curbuf->b_p_ts;
ind_len++;
if (p != NULL) {
*p++ = TAB;
}
}
// Count/add spaces required for indent.
while (todo > 0) {
todo--;
ind_len++;
if (p != NULL) {
*p++ = ' ';
}
}
if (p == NULL) {
// Allocate memory for the result: the copied indent, new indent
// and the rest of the line.
line_len = (int)STRLEN(get_cursor_line_ptr()) + 1;
assert(ind_len + line_len >= 0);
size_t line_size;
STRICT_ADD(ind_len, line_len, &line_size, size_t);
line = xmalloc(line_size);
p = line;
}
}
// Append the original line
memmove(p, get_cursor_line_ptr(), (size_t)line_len);
// Replace the line
ml_replace(curwin->w_cursor.lnum, line, false);
// Put the cursor after the indent.
curwin->w_cursor.col = ind_len;
return true;
}
// Return the indent of the current line after a number. Return -1 if no
// number was found. Used for 'n' in 'formatoptions': numbered list.
// Since a pattern is used it can actually handle more than numbers.

View File

@ -23,6 +23,7 @@
#include "nvim/cursor.h"
#include "nvim/undo.h"
#include "nvim/ascii.h"
#include "nvim/change.h"
#ifdef WIN32
#include "nvim/os/os.h"

View File

@ -47,6 +47,7 @@
#include "nvim/vim.h"
#include "nvim/memline.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/eval.h"
#include "nvim/getchar.h"
@ -1178,7 +1179,7 @@ void ml_recover(void)
/* Recovering an empty file results in two lines and the first line is
* empty. Don't set the modified flag then. */
if (!(curbuf->b_ml.ml_line_count == 2 && *ml_get(1) == NUL)) {
changed_int();
changed_internal();
buf_inc_changedtick(curbuf);
}
} else {
@ -1188,7 +1189,7 @@ void ml_recover(void)
i = STRCMP(p, ml_get(idx + lnum));
xfree(p);
if (i != 0) {
changed_int();
changed_internal();
buf_inc_changedtick(curbuf);
break;
}

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
#include "nvim/ascii.h"
#include "nvim/normal.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"

View File

@ -15,6 +15,7 @@
#include "nvim/ascii.h"
#include "nvim/ops.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/assert.h"

View File

@ -84,6 +84,7 @@
#include "nvim/ascii.h"
#include "nvim/spell.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"

View File

@ -53,6 +53,7 @@
#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/ascii.h"
#include "nvim/getchar.h"
#include "nvim/ui.h"

View File

@ -85,6 +85,7 @@
#include "nvim/buffer.h"
#include "nvim/ascii.h"
#include "nvim/change.h"
#include "nvim/undo.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"