mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: format with uncrustify #15726
This commit is contained in:
parent
490e09c6d8
commit
30fefee684
@ -60,9 +60,9 @@ void do_debug(char_u *cmd)
|
||||
int save_ignore_script = 0;
|
||||
int save_ex_normal_busy;
|
||||
int n;
|
||||
char_u *cmdline = NULL;
|
||||
char_u *p;
|
||||
char *tail = NULL;
|
||||
char_u *cmdline = NULL;
|
||||
char_u *p;
|
||||
char *tail = NULL;
|
||||
static int last_cmd = 0;
|
||||
#define CMD_CONT 1
|
||||
#define CMD_NEXT 2
|
||||
@ -145,13 +145,16 @@ void do_debug(char_u *cmd)
|
||||
p = skipwhite(cmdline);
|
||||
if (*p != NUL) {
|
||||
switch (*p) {
|
||||
case 'c': last_cmd = CMD_CONT;
|
||||
case 'c':
|
||||
last_cmd = CMD_CONT;
|
||||
tail = "ont";
|
||||
break;
|
||||
case 'n': last_cmd = CMD_NEXT;
|
||||
case 'n':
|
||||
last_cmd = CMD_NEXT;
|
||||
tail = "ext";
|
||||
break;
|
||||
case 's': last_cmd = CMD_STEP;
|
||||
case 's':
|
||||
last_cmd = CMD_STEP;
|
||||
tail = "tep";
|
||||
break;
|
||||
case 'f':
|
||||
@ -164,10 +167,12 @@ void do_debug(char_u *cmd)
|
||||
tail = "inish";
|
||||
}
|
||||
break;
|
||||
case 'q': last_cmd = CMD_QUIT;
|
||||
case 'q':
|
||||
last_cmd = CMD_QUIT;
|
||||
tail = "uit";
|
||||
break;
|
||||
case 'i': last_cmd = CMD_INTERRUPT;
|
||||
case 'i':
|
||||
last_cmd = CMD_INTERRUPT;
|
||||
tail = "nterrupt";
|
||||
break;
|
||||
case 'b':
|
||||
@ -190,7 +195,8 @@ void do_debug(char_u *cmd)
|
||||
last_cmd = CMD_DOWN;
|
||||
tail = "own";
|
||||
break;
|
||||
default: last_cmd = 0;
|
||||
default:
|
||||
last_cmd = 0;
|
||||
}
|
||||
if (last_cmd != 0) {
|
||||
// Check that the tail matches.
|
||||
@ -366,7 +372,7 @@ void ex_debug(exarg_T *eap)
|
||||
debug_break_level = debug_break_level_save;
|
||||
}
|
||||
|
||||
static char_u *debug_breakpoint_name = NULL;
|
||||
static char_u *debug_breakpoint_name = NULL;
|
||||
static linenr_T debug_breakpoint_lnum;
|
||||
|
||||
/// When debugging or a breakpoint is set on a skipped command, no debug prompt
|
||||
@ -375,7 +381,7 @@ static linenr_T debug_breakpoint_lnum;
|
||||
/// a skipped command decides itself that a debug prompt should be displayed, it
|
||||
/// can do so by calling dbg_check_skipped().
|
||||
static int debug_skipped;
|
||||
static char_u *debug_skipped_name;
|
||||
static char_u *debug_skipped_name;
|
||||
|
||||
/// Go to debug mode when a breakpoint was encountered or "ex_nesting_level" is
|
||||
/// at or below the break level. But only when the line is actually
|
||||
@ -384,7 +390,7 @@ static char_u *debug_skipped_name;
|
||||
/// Called from do_one_cmd() before executing a command.
|
||||
void dbg_check_breakpoint(exarg_T *eap)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *p;
|
||||
|
||||
debug_skipped = false;
|
||||
if (debug_breakpoint_name != NULL) {
|
||||
@ -474,8 +480,8 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp)
|
||||
/// @param gap either &dbg_breakp or &prof_ga
|
||||
static int dbg_parsearg(char_u *arg, garray_T *gap)
|
||||
{
|
||||
char_u *p = arg;
|
||||
char_u *q;
|
||||
char_u *p = arg;
|
||||
char_u *q;
|
||||
struct debuggy *bp;
|
||||
bool here = false;
|
||||
|
||||
@ -559,7 +565,7 @@ static int dbg_parsearg(char_u *arg, garray_T *gap)
|
||||
void ex_breakadd(exarg_T *eap)
|
||||
{
|
||||
struct debuggy *bp;
|
||||
garray_T *gap;
|
||||
garray_T *gap;
|
||||
|
||||
gap = &dbg_breakp;
|
||||
if (eap->cmdidx == CMD_profile) {
|
||||
@ -614,7 +620,7 @@ void ex_breakdel(exarg_T *eap)
|
||||
int todel = -1;
|
||||
bool del_all = false;
|
||||
linenr_T best_lnum = 0;
|
||||
garray_T *gap;
|
||||
garray_T *gap;
|
||||
|
||||
gap = &dbg_breakp;
|
||||
if (eap->cmdidx == CMD_profdel) {
|
||||
@ -712,12 +718,10 @@ void ex_breaklist(exarg_T *eap)
|
||||
|
||||
/// Find a breakpoint for a function or sourced file.
|
||||
/// Returns line number at which to break; zero when no matching breakpoint.
|
||||
linenr_T
|
||||
dbg_find_breakpoint(
|
||||
bool file, // true for a file, false for a function
|
||||
char_u *fname, // file or function name
|
||||
linenr_T after // after this line number
|
||||
)
|
||||
linenr_T dbg_find_breakpoint(bool file, // true for a file, false for a function
|
||||
char_u *fname, // file or function name
|
||||
linenr_T after // after this line number
|
||||
)
|
||||
{
|
||||
return debuggy_find(file, fname, after, &dbg_breakp, NULL);
|
||||
}
|
||||
@ -734,18 +738,16 @@ bool has_profiling(bool file, char_u *fname, bool *fp)
|
||||
}
|
||||
|
||||
/// Common code for dbg_find_breakpoint() and has_profiling().
|
||||
static linenr_T
|
||||
debuggy_find(
|
||||
bool file, // true for a file, false for a function
|
||||
char_u *fname, // file or function name
|
||||
linenr_T after, // after this line number
|
||||
garray_T *gap, // either &dbg_breakp or &prof_ga
|
||||
bool *fp // if not NULL: return forceit
|
||||
)
|
||||
static linenr_T debuggy_find(bool file, // true for a file, false for a function
|
||||
char_u *fname, // file or function name
|
||||
linenr_T after, // after this line number
|
||||
garray_T *gap, // either &dbg_breakp or &prof_ga
|
||||
bool *fp // if not NULL: return forceit
|
||||
)
|
||||
{
|
||||
struct debuggy *bp;
|
||||
linenr_T lnum = 0;
|
||||
char_u *name = fname;
|
||||
char_u *name = fname;
|
||||
int prev_got_int;
|
||||
|
||||
// Return quickly when there are no breakpoints.
|
||||
|
@ -1,13 +1,13 @@
|
||||
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
||||
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/syntax.h"
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "decoration.c.generated.h"
|
||||
@ -28,11 +28,7 @@ static PMap(uint64_t) hl_decors;
|
||||
/// @param pos_start Cursor position to start the highlighting at
|
||||
/// @param pos_end Cursor position to end the highlighting at
|
||||
/// @param offset Move the whole highlighting this many columns to the right
|
||||
void bufhl_add_hl_pos_offset(buf_T *buf,
|
||||
int src_id,
|
||||
int hl_id,
|
||||
lpos_T pos_start,
|
||||
lpos_T pos_end,
|
||||
void bufhl_add_hl_pos_offset(buf_T *buf, int src_id, int hl_id, lpos_T pos_start, lpos_T pos_end,
|
||||
colnr_T offset)
|
||||
{
|
||||
colnr_T hl_start = 0;
|
||||
@ -172,7 +168,7 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state)
|
||||
ExtmarkItem *item = map_ref(uint64_t, ExtmarkItem)(buf->b_extmark_index,
|
||||
start_id, false);
|
||||
if (!item || !item->decor) {
|
||||
// TODO(bfredl): dedicated flag for being a decoration?
|
||||
// TODO(bfredl): dedicated flag for being a decoration?
|
||||
goto next_mark;
|
||||
}
|
||||
Decoration *decor = item->decor;
|
||||
@ -217,14 +213,14 @@ bool decor_redraw_line(buf_T *buf, int row, DecorState *state)
|
||||
return true; // TODO(bfredl): be more precise
|
||||
}
|
||||
|
||||
static void decor_add(DecorState *state, int start_row, int start_col,
|
||||
int end_row, int end_col, Decoration *decor, bool owned)
|
||||
static void decor_add(DecorState *state, int start_row, int start_col, int end_row, int end_col,
|
||||
Decoration *decor, bool owned)
|
||||
{
|
||||
int attr_id = decor->hl_id > 0 ? syn_id2attr(decor->hl_id) : 0;
|
||||
|
||||
DecorRange range = { start_row, start_col, end_row, end_col,
|
||||
*decor, attr_id,
|
||||
kv_size(decor->virt_text) && owned, -1 };
|
||||
kv_size(decor->virt_text) && owned, -1 };
|
||||
|
||||
kv_pushp(state->active);
|
||||
size_t index;
|
||||
@ -238,8 +234,7 @@ static void decor_add(DecorState *state, int start_row, int start_col,
|
||||
kv_A(state->active, index) = range;
|
||||
}
|
||||
|
||||
int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden,
|
||||
DecorState *state)
|
||||
int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden, DecorState *state)
|
||||
{
|
||||
if (col <= state->col_until) {
|
||||
return state->current;
|
||||
@ -257,7 +252,7 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden,
|
||||
}
|
||||
|
||||
if ((mark.id&MARKTREE_END_FLAG)) {
|
||||
// TODO(bfredl): check decoration flag
|
||||
// TODO(bfredl): check decoration flag
|
||||
goto next_mark;
|
||||
}
|
||||
mtpos_t endpos = marktree_lookup(buf->b_marktree,
|
||||
@ -266,7 +261,7 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden,
|
||||
ExtmarkItem *item = map_ref(uint64_t, ExtmarkItem)(buf->b_extmark_index,
|
||||
mark.id, false);
|
||||
if (!item || !item->decor) {
|
||||
// TODO(bfredl): dedicated flag for being a decoration?
|
||||
// TODO(bfredl): dedicated flag for being a decoration?
|
||||
goto next_mark;
|
||||
}
|
||||
Decoration *decor = item->decor;
|
||||
@ -355,8 +350,7 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col)
|
||||
return has_virttext;
|
||||
}
|
||||
|
||||
void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col,
|
||||
Decoration *decor)
|
||||
void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col, Decoration *decor)
|
||||
{
|
||||
if (end_row == -1) {
|
||||
end_row = start_row;
|
||||
|
114
src/nvim/diff.c
114
src/nvim/diff.c
@ -13,14 +13,12 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "xdiff/xdiff.h"
|
||||
#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/diff.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
@ -29,19 +27,21 @@
|
||||
#include "nvim/mark.h"
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/memline.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/os/shell.h"
|
||||
#include "nvim/path.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/undo.h"
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/os/shell.h"
|
||||
#include "xdiff/xdiff.h"
|
||||
|
||||
static int diff_busy = false; // using diff structs, don't change them
|
||||
static bool diff_need_update = false; // ex_diffupdate needs to be called
|
||||
@ -72,22 +72,22 @@ static TriState diff_a_works = kNone;
|
||||
|
||||
// used for diff input
|
||||
typedef struct {
|
||||
char_u *din_fname; // used for external diff
|
||||
mmfile_t din_mmfile; // used for internal diff
|
||||
char_u *din_fname; // used for external diff
|
||||
mmfile_t din_mmfile; // used for internal diff
|
||||
} diffin_T;
|
||||
|
||||
// used for diff result
|
||||
typedef struct {
|
||||
char_u *dout_fname; // used for external diff
|
||||
garray_T dout_ga; // used for internal diff
|
||||
char_u *dout_fname; // used for external diff
|
||||
garray_T dout_ga; // used for internal diff
|
||||
} diffout_T;
|
||||
|
||||
// two diff inputs and one result
|
||||
typedef struct {
|
||||
diffin_T dio_orig; // original file input
|
||||
diffin_T dio_new; // new file input
|
||||
diffout_T dio_diff; // diff result
|
||||
int dio_internal; // using internal diff
|
||||
diffin_T dio_orig; // original file input
|
||||
diffin_T dio_new; // new file input
|
||||
diffout_T dio_diff; // diff result
|
||||
int dio_internal; // using internal diff
|
||||
} diffio_T;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
@ -119,7 +119,6 @@ void diff_buf_delete(buf_T *buf)
|
||||
/// @param win
|
||||
void diff_buf_adjust(win_T *win)
|
||||
{
|
||||
|
||||
if (!win->w_p_diff) {
|
||||
// When there is no window showing a diff for this buffer, remove
|
||||
// it from the diffs.
|
||||
@ -242,8 +241,7 @@ void diff_invalidate(buf_T *buf)
|
||||
/// @param line2
|
||||
/// @param amount
|
||||
/// @param amount_after
|
||||
void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount,
|
||||
long amount_after)
|
||||
void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
|
||||
{
|
||||
// Handle all tab pages that use the current buffer in a diff.
|
||||
FOR_ALL_TABS(tp) {
|
||||
@ -267,8 +265,8 @@ void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount,
|
||||
/// @param line2
|
||||
/// @param amount
|
||||
/// @amount_after
|
||||
static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
|
||||
linenr_T line2, long amount, long amount_after)
|
||||
static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T line2, long amount,
|
||||
long amount_after)
|
||||
{
|
||||
if (diff_internal()) {
|
||||
// Will update diffs before redrawing. Set _invalid to update the
|
||||
@ -299,7 +297,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
|
||||
diff_T *dp = tp->tp_first_diff;
|
||||
|
||||
linenr_T last;
|
||||
linenr_T lnum_deleted = line1; // lnum of remaining deletion
|
||||
linenr_T lnum_deleted = line1; // lnum of remaining deletion
|
||||
int n;
|
||||
int off;
|
||||
for (;;) {
|
||||
@ -323,8 +321,8 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
|
||||
dnext->df_lnum[i] = line1;
|
||||
} else {
|
||||
dnext->df_lnum[i] = line1
|
||||
+ (dprev->df_lnum[i] + dprev->df_count[i])
|
||||
- (dprev->df_lnum[idx] + dprev->df_count[idx]);
|
||||
+ (dprev->df_lnum[i] + dprev->df_count[i])
|
||||
- (dprev->df_lnum[idx] + dprev->df_count[idx]);
|
||||
}
|
||||
dnext->df_count[i] = deleted;
|
||||
}
|
||||
@ -509,7 +507,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
|
||||
/// @param dp
|
||||
///
|
||||
/// @return The new diff block.
|
||||
static diff_T* diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
|
||||
static diff_T * diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
|
||||
{
|
||||
diff_T *dnew = xmalloc(sizeof(*dnew));
|
||||
|
||||
@ -705,9 +703,9 @@ static void clear_diffout(diffout_T *dout)
|
||||
static int diff_write_buffer(buf_T *buf, diffin_T *din)
|
||||
{
|
||||
linenr_T lnum;
|
||||
char_u *s;
|
||||
char_u *s;
|
||||
long len = 0;
|
||||
char_u *ptr;
|
||||
char_u *ptr;
|
||||
|
||||
// xdiff requires one big block of memory with all the text.
|
||||
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) {
|
||||
@ -789,9 +787,7 @@ static int diff_write(buf_T *buf, diffin_T *din)
|
||||
/// @param dio
|
||||
/// @param idx_orig
|
||||
/// @param eap can be NULL
|
||||
static void diff_try_update(diffio_T *dio,
|
||||
int idx_orig,
|
||||
exarg_T *eap)
|
||||
static void diff_try_update(diffio_T *dio, int idx_orig, exarg_T *eap)
|
||||
{
|
||||
buf_T *buf;
|
||||
int idx_new;
|
||||
@ -1090,9 +1086,9 @@ static int diff_file_internal(diffio_T *diffio)
|
||||
/// @return OK or FAIL
|
||||
static int diff_file(diffio_T *dio)
|
||||
{
|
||||
char *tmp_orig = (char *)dio->dio_orig.din_fname;
|
||||
char *tmp_new = (char *)dio->dio_new.din_fname;
|
||||
char *tmp_diff = (char *)dio->dio_diff.dout_fname;
|
||||
char *tmp_orig = (char *)dio->dio_orig.din_fname;
|
||||
char *tmp_new = (char *)dio->dio_new.din_fname;
|
||||
char *tmp_diff = (char *)dio->dio_diff.dout_fname;
|
||||
if (*p_dex != NUL) {
|
||||
// Use 'diffexpr' to generate the diff file.
|
||||
eval_diff(tmp_orig, tmp_new, tmp_diff);
|
||||
@ -1123,9 +1119,9 @@ static int diff_file(diffio_T *dio)
|
||||
(diff_flags & DIFF_IBLANK) ? "-B " : "",
|
||||
(diff_flags & DIFF_ICASE) ? "-i " : "",
|
||||
tmp_orig, tmp_new);
|
||||
append_redir(cmd, len, (char *) p_srr, tmp_diff);
|
||||
append_redir(cmd, len, (char *)p_srr, tmp_diff);
|
||||
block_autocmds(); // Avoid ShellCmdPost stuff
|
||||
(void)call_shell((char_u *) cmd,
|
||||
(void)call_shell((char_u *)cmd,
|
||||
kShellOptFilter | kShellOptSilent | kShellOptDoOut,
|
||||
NULL);
|
||||
unblock_autocmds();
|
||||
@ -1171,8 +1167,8 @@ void ex_diffpatch(exarg_T *eap)
|
||||
#ifdef UNIX
|
||||
// Get the absolute path of the patchfile, changing directory below.
|
||||
fullname = FullName_save((char *)eap->arg, false);
|
||||
esc_name = vim_strsave_shellescape(
|
||||
(fullname != NULL ? (char_u *)fullname : eap->arg), true, true);
|
||||
esc_name =
|
||||
vim_strsave_shellescape((fullname != NULL ? (char_u *)fullname : eap->arg), true, true);
|
||||
#else
|
||||
esc_name = vim_strsave_shellescape(eap->arg, true, true);
|
||||
#endif
|
||||
@ -1324,8 +1320,8 @@ void ex_diffsplit(exarg_T *eap)
|
||||
|
||||
if (bufref_valid(&old_curbuf)) {
|
||||
// Move the cursor position to that of the old window.
|
||||
curwin->w_cursor.lnum = diff_get_corresponding_line(
|
||||
old_curbuf.br_buf, old_curwin->w_cursor.lnum);
|
||||
curwin->w_cursor.lnum = diff_get_corresponding_line(old_curbuf.br_buf,
|
||||
old_curwin->w_cursor.lnum);
|
||||
}
|
||||
}
|
||||
// Now that lines are folded scroll to show the cursor at the same
|
||||
@ -1344,15 +1340,15 @@ void ex_diffthis(exarg_T *eap)
|
||||
|
||||
static void set_diff_option(win_T *wp, int value)
|
||||
{
|
||||
win_T *old_curwin = curwin;
|
||||
win_T *old_curwin = curwin;
|
||||
|
||||
curwin = wp;
|
||||
curbuf = curwin->w_buffer;
|
||||
curbuf->b_ro_locked++;
|
||||
set_option_value("diff", (long)value, NULL, OPT_LOCAL);
|
||||
curbuf->b_ro_locked--;
|
||||
curwin = old_curwin;
|
||||
curbuf = curwin->w_buffer;
|
||||
curwin = wp;
|
||||
curbuf = curwin->w_buffer;
|
||||
curbuf->b_ro_locked++;
|
||||
set_option_value("diff", (long)value, NULL, OPT_LOCAL);
|
||||
curbuf->b_ro_locked--;
|
||||
curwin = old_curwin;
|
||||
curbuf = curwin->w_buffer;
|
||||
}
|
||||
|
||||
|
||||
@ -1724,8 +1720,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
|
||||
/// @param dp
|
||||
/// @param idx_orig
|
||||
/// @param idx_new
|
||||
static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig,
|
||||
int idx_new)
|
||||
static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int idx_new)
|
||||
{
|
||||
long off;
|
||||
|
||||
@ -1769,7 +1764,7 @@ void diff_clear(tabpage_T *tp)
|
||||
/// @return diff status.
|
||||
int diff_check(win_T *wp, linenr_T lnum)
|
||||
{
|
||||
int idx; // index in tp_diffbuf[] for this buffer
|
||||
int idx; // index in tp_diffbuf[] for this buffer
|
||||
diff_T *dp;
|
||||
int maxcount;
|
||||
int i;
|
||||
@ -1912,8 +1907,7 @@ static bool diff_equal_entry(diff_T *dp, int idx1, int idx2)
|
||||
|
||||
// Compare the characters at "p1" and "p2". If they are equal (possibly
|
||||
// ignoring case) return true and set "len" to the number of bytes.
|
||||
static bool diff_equal_char(const char_u *const p1, const char_u *const p2,
|
||||
int *const len)
|
||||
static bool diff_equal_char(const char_u *const p1, const char_u *const p2, int *const len)
|
||||
{
|
||||
const int l = utfc_ptr2len(p1);
|
||||
|
||||
@ -2537,7 +2531,7 @@ void ex_diffgetput(exarg_T *eap)
|
||||
if ((curtab->tp_diffbuf[i] != curbuf)
|
||||
&& (curtab->tp_diffbuf[i] != NULL)
|
||||
&& ((eap->cmdidx != CMD_diffput)
|
||||
|| MODIFIABLE(curtab->tp_diffbuf[i]))) {
|
||||
|| MODIFIABLE(curtab->tp_diffbuf[i]))) {
|
||||
EMSG(_("E101: More than two buffers in diff mode, don't know "
|
||||
"which one to use"));
|
||||
return;
|
||||
@ -2958,7 +2952,7 @@ static linenr_T diff_get_corresponding_line_int(buf_T *buf1, linenr_T lnum1)
|
||||
return curwin->w_cursor.lnum;
|
||||
}
|
||||
baseline = (dp->df_lnum[idx1] + dp->df_count[idx1])
|
||||
- (dp->df_lnum[idx2] + dp->df_count[idx2]);
|
||||
- (dp->df_lnum[idx2] + dp->df_count[idx2]);
|
||||
}
|
||||
|
||||
// If we get here then the cursor is after the last diff
|
||||
@ -3035,11 +3029,8 @@ linenr_T diff_lnum_win(linenr_T lnum, win_T *wp)
|
||||
/// Handle an ED style diff line.
|
||||
/// Return FAIL if the line does not contain diff info.
|
||||
///
|
||||
static int parse_diff_ed(char_u *line,
|
||||
linenr_T *lnum_orig,
|
||||
long *count_orig,
|
||||
linenr_T *lnum_new,
|
||||
long *count_new)
|
||||
static int parse_diff_ed(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new,
|
||||
long *count_new)
|
||||
{
|
||||
char_u *p;
|
||||
long f1, l1, f2, l2;
|
||||
@ -3093,11 +3084,8 @@ static int parse_diff_ed(char_u *line,
|
||||
/// Parses unified diff with zero(!) context lines.
|
||||
/// Return FAIL if there is no diff information in "line".
|
||||
///
|
||||
static int parse_diff_unified(char_u *line,
|
||||
linenr_T *lnum_orig,
|
||||
long *count_orig,
|
||||
linenr_T *lnum_new,
|
||||
long *count_new)
|
||||
static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig,
|
||||
linenr_T *lnum_new, long *count_new)
|
||||
{
|
||||
char_u *p;
|
||||
long oldline, oldcount, newline, newcount;
|
||||
@ -3153,7 +3141,7 @@ static int parse_diff_unified(char_u *line,
|
||||
static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf)
|
||||
{
|
||||
diffout_T *dout = (diffout_T *)priv;
|
||||
char_u *p;
|
||||
char_u *p;
|
||||
|
||||
// The header line always comes by itself, text lines in at least two
|
||||
// parts. We drop the text part.
|
||||
|
@ -6,26 +6,26 @@
|
||||
/// code for digraphs
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/digraph.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/digraph.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/os/input.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/os/input.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
typedef int result_T;
|
||||
|
||||
@ -40,7 +40,7 @@ typedef struct digraph {
|
||||
# include "digraph.c.generated.h"
|
||||
#endif
|
||||
// digraphs added by the user
|
||||
static garray_T user_digraphs = {0, 0, (int)sizeof(digr_T), 10, NULL};
|
||||
static garray_T user_digraphs = { 0, 0, (int)sizeof(digr_T), 10, NULL };
|
||||
|
||||
/// Note: Characters marked with XX are not included literally, because some
|
||||
/// compilers cannot handle them (Amiga SAS/C is the most picky one).
|
||||
@ -49,7 +49,7 @@ static digr_T digraphdefault[] =
|
||||
// digraphs for Unicode from RFC1345
|
||||
// (also work for ISO-8859-1 aka latin1)
|
||||
{
|
||||
{ 'N', 'U', 0x0a }, // LF for NUL
|
||||
{ 'N', 'U', 0x0a }, // LF for NUL
|
||||
{ 'S', 'H', 0x01 },
|
||||
{ 'S', 'X', 0x02 },
|
||||
{ 'E', 'X', 0x03 },
|
||||
@ -1452,12 +1452,12 @@ static digr_T digraphdefault[] =
|
||||
/// @return The digraph.
|
||||
int do_digraph(int c)
|
||||
{
|
||||
static int backspaced; // character before K_BS
|
||||
static int backspaced; // character before K_BS
|
||||
static int lastchar; // last typed character
|
||||
|
||||
if (c == -1) { // init values
|
||||
backspaced = -1;
|
||||
} else if (p_dg) {
|
||||
} else if (p_dg) {
|
||||
if (backspaced >= 0) {
|
||||
c = getdigraph(backspaced, c, false);
|
||||
}
|
||||
@ -1557,7 +1557,7 @@ static int getexactdigraph(int char1, int char2, bool meta_char)
|
||||
// Search user digraphs first.
|
||||
digr_T *dp = (digr_T *)user_digraphs.ga_data;
|
||||
for (int i = 0; i < user_digraphs.ga_len; ++i) {
|
||||
if (((int) dp->char1 == char1) && ((int) dp->char2 == char2)) {
|
||||
if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) {
|
||||
retval = dp->result;
|
||||
break;
|
||||
}
|
||||
@ -1569,7 +1569,7 @@ static int getexactdigraph(int char1, int char2, bool meta_char)
|
||||
dp = digraphdefault;
|
||||
|
||||
for (int i = 0; dp->char1 != 0; ++i) {
|
||||
if (((int) dp->char1 == char1) && ((int) dp->char2 == char2)) {
|
||||
if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) {
|
||||
retval = dp->result;
|
||||
break;
|
||||
}
|
||||
@ -1821,7 +1821,7 @@ typedef struct {
|
||||
/// @return NULL if OK, an error message for failure. This only needs to be
|
||||
/// used when setting the option, not later when the value has already
|
||||
/// been checked.
|
||||
char_u* keymap_init(void)
|
||||
char_u * keymap_init(void)
|
||||
{
|
||||
curbuf->b_kmap_state &= ~KEYMAP_INIT;
|
||||
|
||||
|
2094
src/nvim/eval.c
2094
src/nvim/eval.c
File diff suppressed because it is too large
Load Diff
@ -6,58 +6,58 @@
|
||||
/// Some more functions for command line commands
|
||||
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/vim.h"
|
||||
#ifdef HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/change.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/debugger.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/mark.h"
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/memline.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/os/fs_defs.h"
|
||||
#include "nvim/os/shell.h"
|
||||
#include "nvim/os_unix.h"
|
||||
#include "nvim/path.h"
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/quickfix.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/undo.h"
|
||||
#include "nvim/version.h"
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/os/shell.h"
|
||||
#include "nvim/os/fs_defs.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
|
||||
|
||||
/// Growarray to store info about already sourced scripts.
|
||||
/// Also store the dev/ino, so that we don't have to stat() each
|
||||
/// script when going through the list.
|
||||
typedef struct scriptitem_S {
|
||||
char_u *sn_name;
|
||||
char_u *sn_name;
|
||||
bool file_id_valid;
|
||||
FileID file_id;
|
||||
bool sn_prof_on; ///< true when script is/was profiled
|
||||
@ -115,14 +115,14 @@ struct source_cookie {
|
||||
# include "ex_cmds2.c.generated.h"
|
||||
#endif
|
||||
|
||||
static char_u *profile_fname = NULL;
|
||||
static char_u *profile_fname = NULL;
|
||||
|
||||
/// ":profile cmd args"
|
||||
void ex_profile(exarg_T *eap)
|
||||
{
|
||||
static proftime_T pause_time;
|
||||
|
||||
char_u *e;
|
||||
char_u *e;
|
||||
int len;
|
||||
|
||||
e = skiptowhite(eap->arg);
|
||||
@ -277,7 +277,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
|
||||
/// Dump the profiling info.
|
||||
void profile_dump(void)
|
||||
{
|
||||
FILE *fd;
|
||||
FILE *fd;
|
||||
|
||||
if (profile_fname != NULL) {
|
||||
fd = os_fopen((char *)profile_fname, "w");
|
||||
@ -362,11 +362,11 @@ static void profile_init(scriptitem_T *si)
|
||||
}
|
||||
|
||||
/// Save time when starting to invoke another script or function.
|
||||
void script_prof_save(
|
||||
proftime_T *tm // place to store wait time
|
||||
)
|
||||
///
|
||||
/// @param tm place to store wait time
|
||||
void script_prof_save(proftime_T *tm)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
scriptitem_T *si;
|
||||
|
||||
if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= script_items.ga_len) {
|
||||
si = &SCRIPT_ITEM(current_sctx.sc_sid);
|
||||
@ -380,7 +380,7 @@ void script_prof_save(
|
||||
/// Count time spent in children after invoking another script or function.
|
||||
void script_prof_restore(proftime_T *tm)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
scriptitem_T *si;
|
||||
|
||||
if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= script_items.ga_len) {
|
||||
si = &SCRIPT_ITEM(current_sctx.sc_sid);
|
||||
@ -412,9 +412,9 @@ void prof_inchar_exit(void)
|
||||
/// Dump the profiling results for all scripts in file "fd".
|
||||
static void script_dump_profile(FILE *fd)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
FILE *sfd;
|
||||
sn_prl_T *pp;
|
||||
scriptitem_T *si;
|
||||
FILE *sfd;
|
||||
sn_prl_T *pp;
|
||||
|
||||
for (int id = 1; id <= script_items.ga_len; id++) {
|
||||
si = &SCRIPT_ITEM(id);
|
||||
@ -699,7 +699,7 @@ bool check_changed_any(bool hidden, bool unload)
|
||||
int i;
|
||||
int bufnum = 0;
|
||||
size_t bufcount = 0;
|
||||
int *bufnrs;
|
||||
int *bufnrs;
|
||||
|
||||
// Make a list of all buffers, with the most important ones first.
|
||||
FOR_ALL_BUFFERS(buf) {
|
||||
@ -829,7 +829,7 @@ int check_fname(void)
|
||||
int buf_write_all(buf_T *buf, int forceit)
|
||||
{
|
||||
int retval;
|
||||
buf_T *old_curbuf = curbuf;
|
||||
buf_T *old_curbuf = curbuf;
|
||||
|
||||
retval = (buf_write(buf, buf->b_ffname, buf->b_fname,
|
||||
(linenr_T)1, buf->b_ml.ml_line_count, NULL,
|
||||
@ -852,7 +852,7 @@ int buf_write_all(buf_T *buf, int forceit)
|
||||
/// Return a pointer to the start of the next argument.
|
||||
static char_u *do_one_arg(char_u *str)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *p;
|
||||
bool inbacktick;
|
||||
|
||||
inbacktick = false;
|
||||
@ -936,8 +936,8 @@ static int do_arglist(char_u *str, int what, int after, bool will_edit)
|
||||
{
|
||||
garray_T new_ga;
|
||||
int exp_count;
|
||||
char_u **exp_files;
|
||||
char_u *p;
|
||||
char_u **exp_files;
|
||||
char_u *p;
|
||||
int match;
|
||||
int arg_escaped = true;
|
||||
|
||||
@ -1037,9 +1037,8 @@ static bool editing_arg_idx(win_T *win)
|
||||
|| (win->w_buffer->b_fnum
|
||||
!= WARGLIST(win)[win->w_arg_idx].ae_fnum
|
||||
&& (win->w_buffer->b_ffname == NULL
|
||||
|| !(path_full_compare(
|
||||
alist_name(&WARGLIST(win)[win->w_arg_idx]),
|
||||
win->w_buffer->b_ffname, true, true) & kEqualFiles))));
|
||||
|| !(path_full_compare(alist_name(&WARGLIST(win)[win->w_arg_idx]),
|
||||
win->w_buffer->b_ffname, true, true) & kEqualFiles))));
|
||||
}
|
||||
|
||||
/// Check if window "win" is editing the w_arg_idx file in its argument list.
|
||||
@ -1102,7 +1101,7 @@ void ex_args(exarg_T *eap)
|
||||
xfree(items);
|
||||
}
|
||||
} else if (eap->cmdidx == CMD_arglocal) {
|
||||
garray_T *gap = &curwin->w_alist->al_ga;
|
||||
garray_T *gap = &curwin->w_alist->al_ga;
|
||||
|
||||
// ":argslocal": make a local copy of the global argument list.
|
||||
ga_grow(gap, GARGCOUNT);
|
||||
@ -1158,7 +1157,7 @@ void ex_argument(exarg_T *eap)
|
||||
void do_argfile(exarg_T *eap, int argn)
|
||||
{
|
||||
int other;
|
||||
char_u *p;
|
||||
char_u *p;
|
||||
int old_arg_idx = curwin->w_arg_idx;
|
||||
|
||||
if (argn < 0 || argn >= ARGCOUNT) {
|
||||
@ -1310,9 +1309,9 @@ void ex_argdelete(exarg_T *eap)
|
||||
curwin->w_arg_idx = (int)eap->line1;
|
||||
}
|
||||
if (ARGCOUNT == 0) {
|
||||
curwin->w_arg_idx = 0;
|
||||
curwin->w_arg_idx = 0;
|
||||
} else if (curwin->w_arg_idx >= ARGCOUNT) {
|
||||
curwin->w_arg_idx = ARGCOUNT - 1;
|
||||
curwin->w_arg_idx = ARGCOUNT - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1325,11 +1324,11 @@ void ex_argdelete(exarg_T *eap)
|
||||
void ex_listdo(exarg_T *eap)
|
||||
{
|
||||
int i;
|
||||
win_T *wp;
|
||||
tabpage_T *tp;
|
||||
win_T *wp;
|
||||
tabpage_T *tp;
|
||||
int next_fnum = 0;
|
||||
char_u *save_ei = NULL;
|
||||
char_u *p_shm_save;
|
||||
char_u *save_ei = NULL;
|
||||
char_u *p_shm_save;
|
||||
|
||||
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) {
|
||||
// Don't do syntax HL autocommands. Skipping the syntax file is a
|
||||
@ -1610,9 +1609,9 @@ char_u *get_arglist_name(expand_T *xp FUNC_ATTR_UNUSED, int idx)
|
||||
/// ":compiler[!] {name}"
|
||||
void ex_compiler(exarg_T *eap)
|
||||
{
|
||||
char_u *buf;
|
||||
char_u *old_cur_comp = NULL;
|
||||
char_u *p;
|
||||
char_u *buf;
|
||||
char_u *old_cur_comp = NULL;
|
||||
char_u *p;
|
||||
|
||||
if (*eap->arg == NUL) {
|
||||
// List all compiler scripts.
|
||||
@ -1703,7 +1702,7 @@ void init_pyxversion(void)
|
||||
// otherwise return 0.
|
||||
static int requires_py_version(char_u *filename)
|
||||
{
|
||||
FILE *file;
|
||||
FILE *file;
|
||||
int requires_py_version = 0;
|
||||
int i, lines;
|
||||
|
||||
@ -1940,9 +1939,7 @@ static char_u *get_str_line(int c, void *cookie, int indent, bool do_concat)
|
||||
return ga.ga_data;
|
||||
}
|
||||
|
||||
static int source_using_linegetter(void *cookie,
|
||||
LineGetter fgetline,
|
||||
const char *traceback_name)
|
||||
static int source_using_linegetter(void *cookie, LineGetter fgetline, const char *traceback_name)
|
||||
{
|
||||
char_u *save_sourcing_name = sourcing_name;
|
||||
linenr_T save_sourcing_lnum = sourcing_lnum;
|
||||
@ -1951,7 +1948,7 @@ static int source_using_linegetter(void *cookie,
|
||||
sourcing_name = (char_u *)traceback_name;
|
||||
} else {
|
||||
snprintf((char *)sourcing_name_buf, sizeof(sourcing_name_buf),
|
||||
"%s called at %s:%"PRIdLINENR, traceback_name, save_sourcing_name,
|
||||
"%s called at %s:%" PRIdLINENR, traceback_name, save_sourcing_name,
|
||||
save_sourcing_lnum);
|
||||
sourcing_name = sourcing_name_buf;
|
||||
}
|
||||
@ -1992,8 +1989,8 @@ static void cmd_source_buffer(const exarg_T *const eap)
|
||||
}
|
||||
((char_u *)ga.ga_data)[ga.ga_len - 1] = NUL;
|
||||
const GetStrLineCookie cookie = {
|
||||
.buf = ga.ga_data,
|
||||
.offset = 0,
|
||||
.buf = ga.ga_data,
|
||||
.offset = 0,
|
||||
};
|
||||
if (curbuf->b_fname
|
||||
&& path_with_extension((const char *)curbuf->b_fname, "lua")) {
|
||||
@ -2012,8 +2009,8 @@ static void cmd_source_buffer(const exarg_T *const eap)
|
||||
int do_source_str(const char *cmd, const char *traceback_name)
|
||||
{
|
||||
GetStrLineCookie cookie = {
|
||||
.buf = (char_u *)cmd,
|
||||
.offset = 0,
|
||||
.buf = (char_u *)cmd,
|
||||
.offset = 0,
|
||||
};
|
||||
return source_using_linegetter((void *)&cookie, get_str_line, traceback_name);
|
||||
}
|
||||
@ -2033,16 +2030,16 @@ int do_source_str(const char *cmd, const char *traceback_name)
|
||||
int do_source(char_u *fname, int check_other, int is_vimrc)
|
||||
{
|
||||
struct source_cookie cookie;
|
||||
char_u *save_sourcing_name;
|
||||
char_u *save_sourcing_name;
|
||||
linenr_T save_sourcing_lnum;
|
||||
char_u *p;
|
||||
char_u *fname_exp;
|
||||
char_u *firstline = NULL;
|
||||
char_u *p;
|
||||
char_u *fname_exp;
|
||||
char_u *firstline = NULL;
|
||||
int retval = FAIL;
|
||||
static scid_T last_current_SID = 0;
|
||||
static int last_current_SID_seq = 0;
|
||||
int save_debug_break_level = debug_break_level;
|
||||
scriptitem_T *si = NULL;
|
||||
scriptitem_T *si = NULL;
|
||||
proftime_T wait_start;
|
||||
bool trigger_source_post = false;
|
||||
|
||||
@ -2363,31 +2360,31 @@ char_u *get_scriptname(LastSet last_set, bool *should_free)
|
||||
*should_free = false;
|
||||
|
||||
switch (last_set.script_ctx.sc_sid) {
|
||||
case SID_MODELINE:
|
||||
return (char_u *)_("modeline");
|
||||
case SID_CMDARG:
|
||||
return (char_u *)_("--cmd argument");
|
||||
case SID_CARG:
|
||||
return (char_u *)_("-c argument");
|
||||
case SID_ENV:
|
||||
return (char_u *)_("environment variable");
|
||||
case SID_ERROR:
|
||||
return (char_u *)_("error handler");
|
||||
case SID_WINLAYOUT:
|
||||
return (char_u *)_("changed window size");
|
||||
case SID_LUA:
|
||||
return (char_u *)_("Lua");
|
||||
case SID_API_CLIENT:
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
_("API client (channel id %" PRIu64 ")"),
|
||||
last_set.channel_id);
|
||||
return IObuff;
|
||||
case SID_STR:
|
||||
return (char_u *)_("anonymous :source");
|
||||
default:
|
||||
*should_free = true;
|
||||
return home_replace_save(NULL,
|
||||
SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name);
|
||||
case SID_MODELINE:
|
||||
return (char_u *)_("modeline");
|
||||
case SID_CMDARG:
|
||||
return (char_u *)_("--cmd argument");
|
||||
case SID_CARG:
|
||||
return (char_u *)_("-c argument");
|
||||
case SID_ENV:
|
||||
return (char_u *)_("environment variable");
|
||||
case SID_ERROR:
|
||||
return (char_u *)_("error handler");
|
||||
case SID_WINLAYOUT:
|
||||
return (char_u *)_("changed window size");
|
||||
case SID_LUA:
|
||||
return (char_u *)_("Lua");
|
||||
case SID_API_CLIENT:
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
_("API client (channel id %" PRIu64 ")"),
|
||||
last_set.channel_id);
|
||||
return IObuff;
|
||||
case SID_STR:
|
||||
return (char_u *)_("anonymous :source");
|
||||
default:
|
||||
*should_free = true;
|
||||
return home_replace_save(NULL,
|
||||
SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2403,7 +2400,7 @@ void free_scriptnames(void)
|
||||
|
||||
linenr_T get_sourced_lnum(LineGetter fgetline, void *cookie)
|
||||
{
|
||||
return fgetline == getsourceline
|
||||
return fgetline == getsourceline
|
||||
? ((struct source_cookie *)cookie)->sourcing_lnum
|
||||
: sourcing_lnum;
|
||||
}
|
||||
@ -2476,7 +2473,7 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
}
|
||||
|
||||
if (line != NULL && sp->conv.vc_type != CONV_NONE) {
|
||||
char_u *s;
|
||||
char_u *s;
|
||||
|
||||
// Convert the encoding of the script line.
|
||||
s = string_convert(&sp->conv, line, NULL);
|
||||
@ -2502,7 +2499,7 @@ static char_u *get_one_sourceline(struct source_cookie *sp)
|
||||
garray_T ga;
|
||||
int len;
|
||||
int c;
|
||||
char_u *buf;
|
||||
char_u *buf;
|
||||
#ifdef USE_CRNL
|
||||
int has_cr; // CR-LF found
|
||||
#endif
|
||||
@ -2605,8 +2602,8 @@ retry:
|
||||
/// until later and we need to store the time now.
|
||||
void script_line_start(void)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
sn_prl_T *pp;
|
||||
scriptitem_T *si;
|
||||
sn_prl_T *pp;
|
||||
|
||||
if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) {
|
||||
return;
|
||||
@ -2637,7 +2634,7 @@ void script_line_start(void)
|
||||
/// Called when actually executing a function line.
|
||||
void script_line_exec(void)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
scriptitem_T *si;
|
||||
|
||||
if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) {
|
||||
return;
|
||||
@ -2651,8 +2648,8 @@ void script_line_exec(void)
|
||||
/// Called when done with a function line.
|
||||
void script_line_end(void)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
sn_prl_T *pp;
|
||||
scriptitem_T *si;
|
||||
sn_prl_T *pp;
|
||||
|
||||
if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) {
|
||||
return;
|
||||
@ -2677,8 +2674,8 @@ void script_line_end(void)
|
||||
/// Without the multi-byte feature it's simply ignored.
|
||||
void ex_scriptencoding(exarg_T *eap)
|
||||
{
|
||||
struct source_cookie *sp;
|
||||
char_u *name;
|
||||
struct source_cookie *sp;
|
||||
char_u *name;
|
||||
|
||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline)) {
|
||||
EMSG(_("E167: :scriptencoding used outside of a sourced file"));
|
||||
@ -2743,14 +2740,13 @@ void do_finish(exarg_T *eap, int reanimate)
|
||||
bool source_finished(LineGetter fgetline, void *cookie)
|
||||
{
|
||||
return getline_equal(fgetline, cookie, getsourceline)
|
||||
&& ((struct source_cookie *)getline_cookie(
|
||||
fgetline, cookie))->finished;
|
||||
&& ((struct source_cookie *)getline_cookie(fgetline, cookie))->finished;
|
||||
}
|
||||
|
||||
/// ":checktime [buffer]"
|
||||
void ex_checktime(exarg_T *eap)
|
||||
{
|
||||
buf_T *buf;
|
||||
buf_T *buf;
|
||||
int save_no_check_timestamps = no_check_timestamps;
|
||||
|
||||
no_check_timestamps = 0;
|
||||
@ -2817,7 +2813,7 @@ char *get_mess_lang(void)
|
||||
/// Get the language used for messages from the environment.
|
||||
static char_u *get_mess_env(void)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *p;
|
||||
|
||||
p = (char_u *)os_getenv("LC_ALL");
|
||||
if (p == NULL) {
|
||||
@ -2888,11 +2884,11 @@ void set_lang_var(void)
|
||||
///
|
||||
void ex_language(exarg_T *eap)
|
||||
{
|
||||
char *loc;
|
||||
char_u *p;
|
||||
char_u *name;
|
||||
char *loc;
|
||||
char_u *p;
|
||||
char_u *name;
|
||||
int what = LC_ALL;
|
||||
char *whatstr = "";
|
||||
char *whatstr = "";
|
||||
#ifdef LC_MESSAGES
|
||||
# define VIM_LC_MESSAGES LC_MESSAGES
|
||||
#else
|
||||
@ -2931,9 +2927,9 @@ void ex_language(exarg_T *eap)
|
||||
p = get_mess_env();
|
||||
} else {
|
||||
#endif
|
||||
p = (char_u *)setlocale(what, NULL);
|
||||
p = (char_u *)setlocale(what, NULL);
|
||||
#ifdef HAVE_WORKING_LIBINTL
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (p == NULL || *p == NUL) {
|
||||
p = (char_u *)"Unknown";
|
||||
@ -2945,13 +2941,13 @@ void ex_language(exarg_T *eap)
|
||||
loc = "";
|
||||
} else {
|
||||
#endif
|
||||
loc = setlocale(what, (char *)name);
|
||||
loc = setlocale(what, (char *)name);
|
||||
#ifdef LC_NUMERIC
|
||||
// Make sure strtod() uses a decimal point, not a comma.
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
// Make sure strtod() uses a decimal point, not a comma.
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
#endif
|
||||
#ifndef LC_MESSAGES
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (loc == NULL) {
|
||||
EMSG2(_("E197: Cannot set language to \"%s\""), name);
|
||||
@ -2999,7 +2995,7 @@ static bool did_init_locales = false;
|
||||
static char_u **find_locales(void)
|
||||
{
|
||||
garray_T locales_ga;
|
||||
char_u *loc;
|
||||
char_u *loc;
|
||||
char *saveptr = NULL;
|
||||
|
||||
// Find all available locales by running command "locale -a". If this
|
||||
@ -3137,7 +3133,7 @@ static void script_host_do_range(char *name, exarg_T *eap)
|
||||
/// ":drop"
|
||||
/// Opens the first argument in a window. When there are two or more arguments
|
||||
/// the argument list is redefined.
|
||||
void ex_drop(exarg_T *eap)
|
||||
void ex_drop(exarg_T *eap)
|
||||
{
|
||||
bool split = false;
|
||||
buf_T *buf;
|
||||
|
@ -7,23 +7,23 @@
|
||||
///
|
||||
/// Functions for Ex command line for the +eval feature.
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/debugger.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/debugger.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "ex_eval.c.generated.h"
|
||||
@ -111,8 +111,9 @@ int aborting(void)
|
||||
*/
|
||||
void update_force_abort(void)
|
||||
{
|
||||
if (cause_abort)
|
||||
if (cause_abort) {
|
||||
force_abort = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -248,8 +249,9 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
|
||||
*/
|
||||
if (msg_list != NULL) {
|
||||
plist = msg_list;
|
||||
while (*plist != NULL)
|
||||
while (*plist != NULL) {
|
||||
plist = &(*plist)->next;
|
||||
}
|
||||
|
||||
elem = xmalloc(sizeof(struct msglist));
|
||||
elem->msg = vim_strsave(mesg);
|
||||
@ -257,19 +259,20 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
|
||||
elem->throw_msg = NULL;
|
||||
*plist = elem;
|
||||
if (plist == msg_list || severe) {
|
||||
char_u *tmsg;
|
||||
char_u *tmsg;
|
||||
|
||||
/* Skip the extra "Vim " prefix for message "E458". */
|
||||
// Skip the extra "Vim " prefix for message "E458".
|
||||
tmsg = elem->msg;
|
||||
if (STRNCMP(tmsg, "Vim E", 5) == 0
|
||||
&& ascii_isdigit(tmsg[5])
|
||||
&& ascii_isdigit(tmsg[6])
|
||||
&& ascii_isdigit(tmsg[7])
|
||||
&& tmsg[8] == ':'
|
||||
&& tmsg[9] == ' ')
|
||||
&& tmsg[9] == ' ') {
|
||||
(*msg_list)->throw_msg = &tmsg[4];
|
||||
else
|
||||
} else {
|
||||
(*msg_list)->throw_msg = tmsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -281,7 +284,7 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
|
||||
*/
|
||||
static void free_msglist(struct msglist *l)
|
||||
{
|
||||
struct msglist *messages, *next;
|
||||
struct msglist *messages, *next;
|
||||
|
||||
messages = l;
|
||||
while (messages != NULL) {
|
||||
@ -320,16 +323,18 @@ void do_errthrow(cstack_T *cstack, char_u *cmdname)
|
||||
|
||||
/* If no exception is to be thrown or the conversion should be done after
|
||||
* returning to a previous invocation of do_one_cmd(), do nothing. */
|
||||
if (msg_list == NULL || *msg_list == NULL)
|
||||
if (msg_list == NULL || *msg_list == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (throw_exception(*msg_list, ET_ERROR, cmdname) == FAIL)
|
||||
if (throw_exception(*msg_list, ET_ERROR, cmdname) == FAIL) {
|
||||
free_msglist(*msg_list);
|
||||
else {
|
||||
if (cstack != NULL)
|
||||
} else {
|
||||
if (cstack != NULL) {
|
||||
do_throw(cstack);
|
||||
else
|
||||
} else {
|
||||
need_rethrow = TRUE;
|
||||
}
|
||||
}
|
||||
*msg_list = NULL;
|
||||
}
|
||||
@ -357,36 +362,35 @@ int do_intthrow(cstack_T *cstack)
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
// Throw an interrupt exception, so that everything will be aborted
|
||||
// (except for executing finally clauses), until the interrupt exception
|
||||
// is caught; if still uncaught at the top level, the script processing
|
||||
// will be terminated then. - If an interrupt exception is already
|
||||
// being thrown, do nothing.
|
||||
// Throw an interrupt exception, so that everything will be aborted
|
||||
// (except for executing finally clauses), until the interrupt exception
|
||||
// is caught; if still uncaught at the top level, the script processing
|
||||
// will be terminated then. - If an interrupt exception is already
|
||||
// being thrown, do nothing.
|
||||
|
||||
if (current_exception) {
|
||||
if (current_exception->type == ET_INTERRUPT) {
|
||||
return false;
|
||||
}
|
||||
if (current_exception) {
|
||||
if (current_exception->type == ET_INTERRUPT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// An interrupt exception replaces any user or error exception.
|
||||
discard_current_exception();
|
||||
}
|
||||
if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) != FAIL) {
|
||||
do_throw(cstack);
|
||||
}
|
||||
#ifdef THROW_TEST
|
||||
// An interrupt exception replaces any user or error exception.
|
||||
discard_current_exception();
|
||||
}
|
||||
if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) != FAIL) {
|
||||
do_throw(cstack);
|
||||
}
|
||||
#ifdef THROW_TEST
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get an exception message that is to be stored in current_exception->value.
|
||||
char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname,
|
||||
int *should_free)
|
||||
char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free)
|
||||
{
|
||||
char_u *ret, *mesg;
|
||||
char_u *p, *val;
|
||||
char_u *ret, *mesg;
|
||||
char_u *p, *val;
|
||||
|
||||
if (type == ET_ERROR) {
|
||||
*should_free = true;
|
||||
@ -434,7 +438,7 @@ char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname,
|
||||
}
|
||||
} else {
|
||||
*should_free = FALSE;
|
||||
ret = (char_u *) value;
|
||||
ret = (char_u *)value;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -447,7 +451,7 @@ char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname,
|
||||
// error exception.
|
||||
static int throw_exception(void *value, except_type_T type, char_u *cmdname)
|
||||
{
|
||||
except_T *excp;
|
||||
except_T *excp;
|
||||
int should_free;
|
||||
|
||||
/*
|
||||
@ -466,14 +470,16 @@ static int throw_exception(void *value, except_type_T type, char_u *cmdname)
|
||||
|
||||
excp = xmalloc(sizeof(except_T));
|
||||
|
||||
if (type == ET_ERROR)
|
||||
if (type == ET_ERROR) {
|
||||
/* Store the original message and prefix the exception value with
|
||||
* "Vim:" or, if a command name is given, "Vim(cmdname):". */
|
||||
excp->messages = (struct msglist *)value;
|
||||
}
|
||||
|
||||
excp->value = get_exception_string(value, type, cmdname, &should_free);
|
||||
if (excp->value == NULL && should_free)
|
||||
if (excp->value == NULL && should_free) {
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
excp->type = type;
|
||||
excp->throw_name = vim_strsave(sourcing_name == NULL
|
||||
@ -483,24 +489,27 @@ static int throw_exception(void *value, except_type_T type, char_u *cmdname)
|
||||
if (p_verbose >= 13 || debug_break_level > 0) {
|
||||
int save_msg_silent = msg_silent;
|
||||
|
||||
if (debug_break_level > 0)
|
||||
msg_silent = FALSE; /* display messages */
|
||||
else
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = FALSE; // display messages
|
||||
} else {
|
||||
verbose_enter();
|
||||
}
|
||||
++no_wait_return;
|
||||
if (debug_break_level > 0 || *p_vfile == NUL)
|
||||
msg_scroll = TRUE; /* always scroll up, don't overwrite */
|
||||
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
msg_scroll = TRUE; // always scroll up, don't overwrite
|
||||
}
|
||||
smsg(_("Exception thrown: %s"), excp->value);
|
||||
msg_puts("\n"); // don't overwrite this either
|
||||
|
||||
if (debug_break_level > 0 || *p_vfile == NUL)
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
cmdline_row = msg_row;
|
||||
}
|
||||
--no_wait_return;
|
||||
if (debug_break_level > 0)
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = save_msg_silent;
|
||||
else
|
||||
} else {
|
||||
verbose_leave();
|
||||
}
|
||||
}
|
||||
|
||||
current_exception = excp;
|
||||
@ -521,7 +530,7 @@ fail:
|
||||
*/
|
||||
static void discard_exception(except_T *excp, bool was_finished)
|
||||
{
|
||||
char_u *saved_IObuff;
|
||||
char_u *saved_IObuff;
|
||||
|
||||
if (current_exception == excp) {
|
||||
current_exception = NULL;
|
||||
@ -535,13 +544,15 @@ static void discard_exception(except_T *excp, bool was_finished)
|
||||
int save_msg_silent = msg_silent;
|
||||
|
||||
saved_IObuff = vim_strsave(IObuff);
|
||||
if (debug_break_level > 0)
|
||||
msg_silent = FALSE; /* display messages */
|
||||
else
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = FALSE; // display messages
|
||||
} else {
|
||||
verbose_enter();
|
||||
}
|
||||
++no_wait_return;
|
||||
if (debug_break_level > 0 || *p_vfile == NUL)
|
||||
msg_scroll = TRUE; /* always scroll up, don't overwrite */
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
msg_scroll = TRUE; // always scroll up, don't overwrite
|
||||
}
|
||||
smsg(was_finished ? _("Exception finished: %s")
|
||||
: _("Exception discarded: %s"),
|
||||
excp->value);
|
||||
@ -558,10 +569,12 @@ static void discard_exception(except_T *excp, bool was_finished)
|
||||
xstrlcpy((char *)IObuff, (const char *)saved_IObuff, IOSIZE);
|
||||
xfree(saved_IObuff);
|
||||
}
|
||||
if (excp->type != ET_INTERRUPT)
|
||||
if (excp->type != ET_INTERRUPT) {
|
||||
xfree(excp->value);
|
||||
if (excp->type == ET_ERROR)
|
||||
}
|
||||
if (excp->type == ET_ERROR) {
|
||||
free_msglist(excp->messages);
|
||||
}
|
||||
xfree(excp->throw_name);
|
||||
xfree(excp);
|
||||
}
|
||||
@ -586,7 +599,7 @@ static void catch_exception(except_T *excp)
|
||||
{
|
||||
excp->caught = caught_stack;
|
||||
caught_stack = excp;
|
||||
set_vim_var_string(VV_EXCEPTION, (char *) excp->value, -1);
|
||||
set_vim_var_string(VV_EXCEPTION, (char *)excp->value, -1);
|
||||
if (*excp->throw_name != NUL) {
|
||||
if (excp->throw_lnum != 0) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64),
|
||||
@ -594,7 +607,7 @@ static void catch_exception(except_T *excp)
|
||||
} else {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name);
|
||||
}
|
||||
set_vim_var_string(VV_THROWPOINT, (char *) IObuff, -1);
|
||||
set_vim_var_string(VV_THROWPOINT, (char *)IObuff, -1);
|
||||
} else {
|
||||
// throw_name not set on an exception from a command that was typed.
|
||||
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
||||
@ -603,24 +616,27 @@ static void catch_exception(except_T *excp)
|
||||
if (p_verbose >= 13 || debug_break_level > 0) {
|
||||
int save_msg_silent = msg_silent;
|
||||
|
||||
if (debug_break_level > 0)
|
||||
msg_silent = FALSE; /* display messages */
|
||||
else
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = FALSE; // display messages
|
||||
} else {
|
||||
verbose_enter();
|
||||
}
|
||||
++no_wait_return;
|
||||
if (debug_break_level > 0 || *p_vfile == NUL)
|
||||
msg_scroll = TRUE; /* always scroll up, don't overwrite */
|
||||
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
msg_scroll = TRUE; // always scroll up, don't overwrite
|
||||
}
|
||||
smsg(_("Exception caught: %s"), excp->value);
|
||||
msg_puts("\n"); // don't overwrite this either
|
||||
|
||||
if (debug_break_level > 0 || *p_vfile == NUL)
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
cmdline_row = msg_row;
|
||||
}
|
||||
--no_wait_return;
|
||||
if (debug_break_level > 0)
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = save_msg_silent;
|
||||
else
|
||||
} else {
|
||||
verbose_leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -634,7 +650,7 @@ static void finish_exception(except_T *excp)
|
||||
}
|
||||
caught_stack = caught_stack->caught;
|
||||
if (caught_stack != NULL) {
|
||||
set_vim_var_string(VV_EXCEPTION, (char *) caught_stack->value, -1);
|
||||
set_vim_var_string(VV_EXCEPTION, (char *)caught_stack->value, -1);
|
||||
if (*caught_stack->throw_name != NUL) {
|
||||
if (caught_stack->throw_lnum != 0) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
@ -644,7 +660,7 @@ static void finish_exception(except_T *excp)
|
||||
vim_snprintf((char *)IObuff, IOSIZE, "%s",
|
||||
caught_stack->throw_name);
|
||||
}
|
||||
set_vim_var_string(VV_THROWPOINT, (char *) IObuff, -1);
|
||||
set_vim_var_string(VV_THROWPOINT, (char *)IObuff, -1);
|
||||
} else {
|
||||
// throw_name not set on an exception from a command that was
|
||||
// typed.
|
||||
@ -688,7 +704,7 @@ static void report_pending(int action, int pending, void *value)
|
||||
case RP_RESUME:
|
||||
mesg = _("%s resumed");
|
||||
break;
|
||||
/* case RP_DISCARD: */
|
||||
// case RP_DISCARD:
|
||||
default:
|
||||
mesg = _("%s discarded");
|
||||
break;
|
||||
@ -708,7 +724,7 @@ static void report_pending(int action, int pending, void *value)
|
||||
s = ":finish";
|
||||
break;
|
||||
case CSTP_RETURN:
|
||||
/* ":return" command producing value, allocated */
|
||||
// ":return" command producing value, allocated
|
||||
s = (char *)get_return_cmd(value);
|
||||
break;
|
||||
|
||||
@ -718,30 +734,34 @@ static void report_pending(int action, int pending, void *value)
|
||||
mesg, _("Exception"));
|
||||
mesg = (char *)concat_str(IObuff, (char_u *)": %s");
|
||||
s = (char *)((except_T *)value)->value;
|
||||
} else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT))
|
||||
} else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) {
|
||||
s = _("Error and interrupt");
|
||||
else if (pending & CSTP_ERROR)
|
||||
} else if (pending & CSTP_ERROR) {
|
||||
s = _("Error");
|
||||
else /* if (pending & CSTP_INTERRUPT) */
|
||||
} else { // if (pending & CSTP_INTERRUPT)
|
||||
s = _("Interrupt");
|
||||
}
|
||||
}
|
||||
|
||||
save_msg_silent = msg_silent;
|
||||
if (debug_break_level > 0)
|
||||
msg_silent = FALSE; /* display messages */
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = FALSE; // display messages
|
||||
}
|
||||
++no_wait_return;
|
||||
msg_scroll = TRUE; /* always scroll up, don't overwrite */
|
||||
msg_scroll = TRUE; // always scroll up, don't overwrite
|
||||
smsg(mesg, s);
|
||||
msg_puts("\n"); // don't overwrite this either
|
||||
cmdline_row = msg_row;
|
||||
--no_wait_return;
|
||||
if (debug_break_level > 0)
|
||||
if (debug_break_level > 0) {
|
||||
msg_silent = save_msg_silent;
|
||||
}
|
||||
|
||||
if (pending == CSTP_RETURN)
|
||||
if (pending == CSTP_RETURN) {
|
||||
xfree(s);
|
||||
else if (pending & CSTP_THROW)
|
||||
} else if (pending & CSTP_THROW) {
|
||||
xfree(mesg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -751,11 +771,13 @@ static void report_pending(int action, int pending, void *value)
|
||||
void report_make_pending(int pending, void *value)
|
||||
{
|
||||
if (p_verbose >= 14 || debug_break_level > 0) {
|
||||
if (debug_break_level <= 0)
|
||||
if (debug_break_level <= 0) {
|
||||
verbose_enter();
|
||||
}
|
||||
report_pending(RP_MAKE, pending, value);
|
||||
if (debug_break_level <= 0)
|
||||
if (debug_break_level <= 0) {
|
||||
verbose_leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,11 +788,13 @@ void report_make_pending(int pending, void *value)
|
||||
void report_resume_pending(int pending, void *value)
|
||||
{
|
||||
if (p_verbose >= 14 || debug_break_level > 0) {
|
||||
if (debug_break_level <= 0)
|
||||
if (debug_break_level <= 0) {
|
||||
verbose_enter();
|
||||
}
|
||||
report_pending(RP_RESUME, pending, value);
|
||||
if (debug_break_level <= 0)
|
||||
if (debug_break_level <= 0) {
|
||||
verbose_leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -781,11 +805,13 @@ void report_resume_pending(int pending, void *value)
|
||||
void report_discard_pending(int pending, void *value)
|
||||
{
|
||||
if (p_verbose >= 14 || debug_break_level > 0) {
|
||||
if (debug_break_level <= 0)
|
||||
if (debug_break_level <= 0) {
|
||||
verbose_enter();
|
||||
}
|
||||
report_pending(RP_DISCARD, pending, value);
|
||||
if (debug_break_level <= 0)
|
||||
if (debug_break_level <= 0) {
|
||||
verbose_leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -808,9 +834,9 @@ void ex_if(exarg_T *eap)
|
||||
int result;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
if (cstack->cs_idx == CSTACK_LEN - 1)
|
||||
if (cstack->cs_idx == CSTACK_LEN - 1) {
|
||||
eap->errmsg = (char_u *)N_("E579: :if nesting too deep");
|
||||
else {
|
||||
} else {
|
||||
++cstack->cs_idx;
|
||||
cstack->cs_flags[cstack->cs_idx] = 0;
|
||||
|
||||
@ -820,11 +846,13 @@ void ex_if(exarg_T *eap)
|
||||
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
|
||||
|
||||
if (!skip && !error) {
|
||||
if (result)
|
||||
if (result) {
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE;
|
||||
} else
|
||||
/* set TRUE, so this conditional will never get active */
|
||||
}
|
||||
} else {
|
||||
// set TRUE, so this conditional will never get active
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -884,13 +912,15 @@ void ex_else(exarg_T *eap)
|
||||
skip = TRUE;
|
||||
}
|
||||
|
||||
/* if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it */
|
||||
// if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it
|
||||
if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE) {
|
||||
if (eap->errmsg == NULL)
|
||||
if (eap->errmsg == NULL) {
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
|
||||
skip = TRUE; /* don't evaluate an ":elseif" */
|
||||
} else
|
||||
}
|
||||
skip = TRUE; // don't evaluate an ":elseif"
|
||||
} else {
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE;
|
||||
}
|
||||
|
||||
/*
|
||||
* When debugging or a breakpoint was encountered, display the debug prompt
|
||||
@ -917,15 +947,18 @@ void ex_else(exarg_T *eap)
|
||||
* case, the parsing error will be ignored by emsg(). */
|
||||
|
||||
if (!skip && !error) {
|
||||
if (result)
|
||||
if (result) {
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE;
|
||||
else
|
||||
} else {
|
||||
cstack->cs_flags[cstack->cs_idx] = 0;
|
||||
} else if (eap->errmsg == NULL)
|
||||
/* set TRUE, so this conditional will never get active */
|
||||
}
|
||||
} else if (eap->errmsg == NULL) {
|
||||
// set TRUE, so this conditional will never get active
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
cstack->cs_flags[cstack->cs_idx] |= CSF_ELSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -938,9 +971,9 @@ void ex_while(exarg_T *eap)
|
||||
int result;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
if (cstack->cs_idx == CSTACK_LEN - 1)
|
||||
if (cstack->cs_idx == CSTACK_LEN - 1) {
|
||||
eap->errmsg = (char_u *)N_("E585: :while/:for nesting too deep");
|
||||
else {
|
||||
} else {
|
||||
/*
|
||||
* The loop flag is set when we have jumped back from the matching
|
||||
* ":endwhile" or ":endfor". When not set, need to initialise this
|
||||
@ -972,16 +1005,17 @@ void ex_while(exarg_T *eap)
|
||||
fi = cstack->cs_forinfo[cstack->cs_idx];
|
||||
error = FALSE;
|
||||
} else {
|
||||
/* Evaluate the argument and get the info in a structure. */
|
||||
// Evaluate the argument and get the info in a structure.
|
||||
fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip);
|
||||
cstack->cs_forinfo[cstack->cs_idx] = fi;
|
||||
}
|
||||
|
||||
/* use the element at the start of the list and advance */
|
||||
if (!error && fi != NULL && !skip)
|
||||
// use the element at the start of the list and advance
|
||||
if (!error && fi != NULL && !skip) {
|
||||
result = next_for_item(fi, eap->arg);
|
||||
else
|
||||
} else {
|
||||
result = FALSE;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
free_for_info(fi);
|
||||
@ -1003,8 +1037,9 @@ void ex_while(exarg_T *eap)
|
||||
* the list, show the debug prompt at the ":endwhile"/":endfor" as
|
||||
* if there was a ":break" in a ":while"/":for" evaluating to
|
||||
* TRUE. */
|
||||
if (!skip && !error)
|
||||
if (!skip && !error) {
|
||||
cstack->cs_flags[cstack->cs_idx] |= CSF_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1017,9 +1052,9 @@ void ex_continue(exarg_T *eap)
|
||||
int idx;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
|
||||
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
|
||||
eap->errmsg = (char_u *)N_("E586: :continue without :while or :for");
|
||||
else {
|
||||
} else {
|
||||
/* Try to find the matching ":while". This might stop at a try
|
||||
* conditional not in its finally clause (which is then to be executed
|
||||
* next). Therefore, deactivate all conditionals except the ":while"
|
||||
@ -1033,7 +1068,7 @@ void ex_continue(exarg_T *eap)
|
||||
* Set CSL_HAD_CONT, so do_cmdline() will jump back to the
|
||||
* matching ":while".
|
||||
*/
|
||||
cstack->cs_lflags |= CSL_HAD_CONT; /* let do_cmdline() handle it */
|
||||
cstack->cs_lflags |= CSL_HAD_CONT; // let do_cmdline() handle it
|
||||
} else {
|
||||
/* If a try conditional not in its finally clause is reached first,
|
||||
* make the ":continue" pending for execution at the ":endtry". */
|
||||
@ -1073,7 +1108,7 @@ void ex_endwhile(exarg_T *eap)
|
||||
{
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
int idx;
|
||||
char_u *err;
|
||||
char_u *err;
|
||||
int csf;
|
||||
int fl;
|
||||
|
||||
@ -1085,24 +1120,26 @@ void ex_endwhile(exarg_T *eap)
|
||||
csf = CSF_FOR;
|
||||
}
|
||||
|
||||
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
|
||||
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
|
||||
eap->errmsg = err;
|
||||
else {
|
||||
} else {
|
||||
fl = cstack->cs_flags[cstack->cs_idx];
|
||||
if (!(fl & csf)) {
|
||||
/* If we are in a ":while" or ":for" but used the wrong endloop
|
||||
* command, do not rewind to the next enclosing ":for"/":while". */
|
||||
if (fl & CSF_WHILE)
|
||||
if (fl & CSF_WHILE) {
|
||||
eap->errmsg = (char_u *)_("E732: Using :endfor with :while");
|
||||
else if (fl & CSF_FOR)
|
||||
} else if (fl & CSF_FOR) {
|
||||
eap->errmsg = (char_u *)_("E733: Using :endwhile with :for");
|
||||
}
|
||||
}
|
||||
if (!(fl & (CSF_WHILE | CSF_FOR))) {
|
||||
if (!(fl & CSF_TRY))
|
||||
if (!(fl & CSF_TRY)) {
|
||||
eap->errmsg = e_endif;
|
||||
else if (fl & CSF_FINALLY)
|
||||
} else if (fl & CSF_FINALLY) {
|
||||
eap->errmsg = e_endtry;
|
||||
/* Try to find the matching ":while" and report what's missing. */
|
||||
}
|
||||
// Try to find the matching ":while" and report what's missing.
|
||||
for (idx = cstack->cs_idx; idx > 0; --idx) {
|
||||
fl = cstack->cs_flags[idx];
|
||||
if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) {
|
||||
@ -1111,10 +1148,11 @@ void ex_endwhile(exarg_T *eap)
|
||||
eap->errmsg = err;
|
||||
return;
|
||||
}
|
||||
if (fl & csf)
|
||||
if (fl & csf) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Cleanup and rewind all contained (and unclosed) conditionals. */
|
||||
// Cleanup and rewind all contained (and unclosed) conditionals.
|
||||
(void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
|
||||
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
|
||||
}
|
||||
@ -1130,8 +1168,9 @@ void ex_endwhile(exarg_T *eap)
|
||||
*/
|
||||
else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE
|
||||
&& !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)
|
||||
&& dbg_check_skipped(eap))
|
||||
&& dbg_check_skipped(eap)) {
|
||||
(void)do_intthrow(cstack);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set loop flag, so do_cmdline() will jump back to the matching
|
||||
@ -1216,13 +1255,14 @@ void do_throw(cstack_T *cstack)
|
||||
* the matching catch clause or the finally clause.
|
||||
*/
|
||||
if (!(cstack->cs_flags[idx] & CSF_CAUGHT)) {
|
||||
if (cstack->cs_flags[idx] & CSF_ACTIVE)
|
||||
if (cstack->cs_flags[idx] & CSF_ACTIVE) {
|
||||
cstack->cs_flags[idx] |= CSF_THROWN;
|
||||
else
|
||||
} else {
|
||||
/* THROWN may have already been set for a catchable exception
|
||||
* that has been discarded. Ensure it is reset for the new
|
||||
* exception. */
|
||||
cstack->cs_flags[idx] &= ~CSF_THROWN;
|
||||
}
|
||||
}
|
||||
cstack->cs_flags[idx] &= ~CSF_ACTIVE;
|
||||
cstack->cs_exception[idx] = current_exception;
|
||||
@ -1237,9 +1277,9 @@ void ex_try(exarg_T *eap)
|
||||
int skip;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
if (cstack->cs_idx == CSTACK_LEN - 1)
|
||||
if (cstack->cs_idx == CSTACK_LEN - 1) {
|
||||
eap->errmsg = (char_u *)N_("E601: :try nesting too deep");
|
||||
else {
|
||||
} else {
|
||||
++cstack->cs_idx;
|
||||
++cstack->cs_trylevel;
|
||||
cstack->cs_flags[cstack->cs_idx] = CSF_TRY;
|
||||
@ -1278,7 +1318,6 @@ void ex_try(exarg_T *eap)
|
||||
emsg_silent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1291,13 +1330,13 @@ void ex_catch(exarg_T *eap)
|
||||
int give_up = FALSE;
|
||||
int skip = FALSE;
|
||||
int caught = FALSE;
|
||||
char_u *end;
|
||||
char_u *end;
|
||||
char_u save_char = 0;
|
||||
char_u *save_cpo;
|
||||
char_u *save_cpo;
|
||||
regmatch_T regmatch;
|
||||
int prev_got_int;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
char_u *pat;
|
||||
char_u *pat;
|
||||
|
||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
|
||||
eap->errmsg = (char_u *)N_("E603: :catch without :try");
|
||||
@ -1309,20 +1348,23 @@ void ex_catch(exarg_T *eap)
|
||||
eap->errmsg = get_end_emsg(cstack);
|
||||
skip = TRUE;
|
||||
}
|
||||
for (idx = cstack->cs_idx; idx > 0; --idx)
|
||||
if (cstack->cs_flags[idx] & CSF_TRY)
|
||||
for (idx = cstack->cs_idx; idx > 0; --idx) {
|
||||
if (cstack->cs_flags[idx] & CSF_TRY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cstack->cs_flags[idx] & CSF_FINALLY) {
|
||||
/* Give up for a ":catch" after ":finally" and ignore it.
|
||||
* Just parse. */
|
||||
eap->errmsg = (char_u *)N_("E604: :catch after :finally");
|
||||
give_up = TRUE;
|
||||
} else
|
||||
} else {
|
||||
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
|
||||
&cstack->cs_looplevel);
|
||||
&cstack->cs_looplevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (ends_excmd(*eap->arg)) { /* no argument, catch all errors */
|
||||
if (ends_excmd(*eap->arg)) { // no argument, catch all errors
|
||||
pat = (char_u *)".*";
|
||||
end = NULL;
|
||||
eap->nextcmd = find_nextcmd(eap->arg);
|
||||
@ -1390,7 +1432,7 @@ void ex_catch(exarg_T *eap)
|
||||
prev_got_int = got_int;
|
||||
got_int = FALSE;
|
||||
caught = vim_regexec_nl(®match, current_exception->value,
|
||||
(colnr_T)0);
|
||||
(colnr_T)0);
|
||||
got_int |= prev_got_int;
|
||||
vim_regfree(regmatch.regprog);
|
||||
}
|
||||
@ -1430,8 +1472,9 @@ void ex_catch(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
|
||||
if (end != NULL)
|
||||
if (end != NULL) {
|
||||
eap->nextcmd = find_nextcmd(end);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1444,28 +1487,31 @@ void ex_finally(exarg_T *eap)
|
||||
int pending = CSTP_NONE;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
|
||||
eap->errmsg = (char_u *)N_("E606: :finally without :try");
|
||||
else {
|
||||
} else {
|
||||
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
|
||||
eap->errmsg = get_end_emsg(cstack);
|
||||
for (idx = cstack->cs_idx - 1; idx > 0; --idx)
|
||||
if (cstack->cs_flags[idx] & CSF_TRY)
|
||||
for (idx = cstack->cs_idx - 1; idx > 0; --idx) {
|
||||
if (cstack->cs_flags[idx] & CSF_TRY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Make this error pending, so that the commands in the following
|
||||
* finally clause can be executed. This overrules also a pending
|
||||
* ":continue", ":break", ":return", or ":finish". */
|
||||
pending = CSTP_ERROR;
|
||||
} else
|
||||
} else {
|
||||
idx = cstack->cs_idx;
|
||||
}
|
||||
|
||||
if (cstack->cs_flags[idx] & CSF_FINALLY) {
|
||||
/* Give up for a multiple ":finally" and ignore it. */
|
||||
// Give up for a multiple ":finally" and ignore it.
|
||||
eap->errmsg = (char_u *)N_("E607: multiple :finally");
|
||||
return;
|
||||
}
|
||||
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
|
||||
&cstack->cs_looplevel);
|
||||
&cstack->cs_looplevel);
|
||||
|
||||
/*
|
||||
* Don't do something when the corresponding try block never got active
|
||||
@ -1517,7 +1563,7 @@ void ex_finally(exarg_T *eap)
|
||||
if (pending == CSTP_ERROR || did_emsg || got_int || current_exception) {
|
||||
if (cstack->cs_pending[cstack->cs_idx] == CSTP_RETURN) {
|
||||
report_discard_pending(CSTP_RETURN,
|
||||
cstack->cs_rettv[cstack->cs_idx]);
|
||||
cstack->cs_rettv[cstack->cs_idx]);
|
||||
discard_pending_return(cstack->cs_rettv[cstack->cs_idx]);
|
||||
}
|
||||
if (pending == CSTP_ERROR && !did_emsg) {
|
||||
@ -1564,7 +1610,7 @@ void ex_endtry(exarg_T *eap)
|
||||
int skip;
|
||||
int rethrow = FALSE;
|
||||
int pending = CSTP_NONE;
|
||||
void *rettv = NULL;
|
||||
void *rettv = NULL;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
|
||||
@ -1585,13 +1631,13 @@ void ex_endtry(exarg_T *eap)
|
||||
|
||||
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
|
||||
eap->errmsg = get_end_emsg(cstack);
|
||||
/* Find the matching ":try" and report what's missing. */
|
||||
// Find the matching ":try" and report what's missing.
|
||||
idx = cstack->cs_idx;
|
||||
do
|
||||
--idx;
|
||||
while (idx > 0 && !(cstack->cs_flags[idx] & CSF_TRY));
|
||||
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
|
||||
&cstack->cs_looplevel);
|
||||
&cstack->cs_looplevel);
|
||||
skip = TRUE;
|
||||
|
||||
/*
|
||||
@ -1656,10 +1702,11 @@ void ex_endtry(exarg_T *eap)
|
||||
if (!skip) {
|
||||
pending = cstack->cs_pending[idx];
|
||||
cstack->cs_pending[idx] = CSTP_NONE;
|
||||
if (pending == CSTP_RETURN)
|
||||
if (pending == CSTP_RETURN) {
|
||||
rettv = cstack->cs_rettv[idx];
|
||||
else if (pending & CSTP_THROW)
|
||||
} else if (pending & CSTP_THROW) {
|
||||
current_exception = cstack->cs_exception[idx];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1679,8 +1726,8 @@ void ex_endtry(exarg_T *eap)
|
||||
|
||||
if (!skip) {
|
||||
report_resume_pending(pending,
|
||||
(pending == CSTP_RETURN) ? rettv :
|
||||
(pending & CSTP_THROW) ? (void *)current_exception : NULL);
|
||||
(pending == CSTP_RETURN) ? rettv :
|
||||
(pending & CSTP_THROW) ? (void *)current_exception : NULL);
|
||||
switch (pending) {
|
||||
case CSTP_NONE:
|
||||
break;
|
||||
@ -1788,7 +1835,7 @@ void enter_cleanup(cleanup_T *csp)
|
||||
did_emsg = got_int = need_rethrow = false;
|
||||
current_exception = NULL;
|
||||
|
||||
/* Report if required by the 'verbose' option or when debugging. */
|
||||
// Report if required by the 'verbose' option or when debugging.
|
||||
report_make_pending(pending, csp->exception);
|
||||
} else {
|
||||
csp->pending = CSTP_NONE;
|
||||
@ -1815,8 +1862,9 @@ void leave_cleanup(cleanup_T *csp)
|
||||
{
|
||||
int pending = csp->pending;
|
||||
|
||||
if (pending == CSTP_NONE) /* nothing to do */
|
||||
if (pending == CSTP_NONE) { // nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
/* If there was an aborting error, an interrupt, or an uncaught exception
|
||||
* after the corresponding call to enter_cleanup(), discard what has been
|
||||
@ -1832,8 +1880,9 @@ void leave_cleanup(cleanup_T *csp)
|
||||
|
||||
/* If an error was about to be converted to an exception when
|
||||
* enter_cleanup() was called, free the message list. */
|
||||
if (msg_list != NULL)
|
||||
if (msg_list != NULL) {
|
||||
free_global_msglist();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If there was no new error, interrupt, or throw between the calls
|
||||
@ -1846,9 +1895,9 @@ void leave_cleanup(cleanup_T *csp)
|
||||
* called, we need to rethrow it. Make it the exception currently
|
||||
* being thrown.
|
||||
*/
|
||||
if (pending & CSTP_THROW)
|
||||
if (pending & CSTP_THROW) {
|
||||
current_exception = csp->exception;
|
||||
|
||||
}
|
||||
/*
|
||||
* If an error was about to be converted to an exception when
|
||||
* enter_cleanup() was called, let "cause_abort" take the part of
|
||||
@ -1871,8 +1920,7 @@ void leave_cleanup(cleanup_T *csp)
|
||||
}
|
||||
|
||||
// Report if required by the 'verbose' option or when debugging.
|
||||
report_resume_pending(
|
||||
pending, ((pending & CSTP_THROW) ? (void *)current_exception : NULL));
|
||||
report_resume_pending(pending, ((pending & CSTP_THROW) ? (void *)current_exception : NULL));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1920,7 +1968,7 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
|
||||
|
||||
case CSTP_RETURN:
|
||||
report_discard_pending(CSTP_RETURN,
|
||||
cstack->cs_rettv[idx]);
|
||||
cstack->cs_rettv[idx]);
|
||||
discard_pending_return(cstack->cs_rettv[idx]);
|
||||
cstack->cs_pending[idx] = CSTP_NONE;
|
||||
break;
|
||||
@ -1948,15 +1996,17 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
|
||||
*/
|
||||
if (!(cstack->cs_flags[idx] & CSF_FINALLY)) {
|
||||
if ((cstack->cs_flags[idx] & CSF_ACTIVE)
|
||||
&& (cstack->cs_flags[idx] & CSF_CAUGHT))
|
||||
&& (cstack->cs_flags[idx] & CSF_CAUGHT)) {
|
||||
finish_exception((except_T *)cstack->cs_exception[idx]);
|
||||
}
|
||||
/* Stop at this try conditional - except the try block never
|
||||
* got active (because of an inactive surrounding conditional
|
||||
* or when the ":try" appeared after an error or interrupt or
|
||||
* throw). */
|
||||
if (cstack->cs_flags[idx] & CSF_TRUE) {
|
||||
if (searched_cond == 0 && !inclusive)
|
||||
if (searched_cond == 0 && !inclusive) {
|
||||
break;
|
||||
}
|
||||
stop = TRUE;
|
||||
}
|
||||
}
|
||||
@ -1967,13 +2017,15 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
|
||||
* If "inclusive" is TRUE and "searched_cond" is CSF_TRY|CSF_SILENT,
|
||||
* check first whether "emsg_silent" needs to be restored. */
|
||||
if (cstack->cs_flags[idx] & searched_cond) {
|
||||
if (!inclusive)
|
||||
if (!inclusive) {
|
||||
break;
|
||||
}
|
||||
stop = TRUE;
|
||||
}
|
||||
cstack->cs_flags[idx] &= ~CSF_ACTIVE;
|
||||
if (stop && searched_cond != (CSF_TRY | CSF_SILENT))
|
||||
if (stop && searched_cond != (CSF_TRY | CSF_SILENT)) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* When leaving a try conditional that reset "emsg_silent" on its
|
||||
@ -1982,7 +2034,7 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
|
||||
*/
|
||||
if ((cstack->cs_flags[idx] & CSF_TRY)
|
||||
&& (cstack->cs_flags[idx] & CSF_SILENT)) {
|
||||
eslist_T *elem;
|
||||
eslist_T *elem;
|
||||
|
||||
elem = cstack->cs_emsg_silent_list;
|
||||
cstack->cs_emsg_silent_list = elem->next;
|
||||
@ -1990,8 +2042,9 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
|
||||
xfree(elem);
|
||||
cstack->cs_flags[idx] &= ~CSF_SILENT;
|
||||
}
|
||||
if (stop)
|
||||
if (stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
@ -2001,10 +2054,12 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
|
||||
*/
|
||||
static char_u *get_end_emsg(cstack_T *cstack)
|
||||
{
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE)
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) {
|
||||
return e_endwhile;
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR)
|
||||
}
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) {
|
||||
return e_endfor;
|
||||
}
|
||||
return e_endif;
|
||||
}
|
||||
|
||||
@ -2016,14 +2071,15 @@ static char_u *get_end_emsg(cstack_T *cstack)
|
||||
* type.
|
||||
* Also free "for info" structures where needed.
|
||||
*/
|
||||
void rewind_conditionals(cstack_T *cstack, int idx, int cond_type,
|
||||
int *cond_level)
|
||||
void rewind_conditionals(cstack_T *cstack, int idx, int cond_type, int *cond_level)
|
||||
{
|
||||
while (cstack->cs_idx > idx) {
|
||||
if (cstack->cs_flags[cstack->cs_idx] & cond_type)
|
||||
if (cstack->cs_flags[cstack->cs_idx] & cond_type) {
|
||||
--*cond_level;
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR)
|
||||
}
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) {
|
||||
free_for_info(cstack->cs_forinfo[cstack->cs_idx]);
|
||||
}
|
||||
--cstack->cs_idx;
|
||||
}
|
||||
}
|
||||
@ -2043,18 +2099,21 @@ int has_loop_cmd(char_u *p)
|
||||
{
|
||||
int len;
|
||||
|
||||
/* skip modifiers, white space and ':' */
|
||||
// skip modifiers, white space and ':'
|
||||
for (;; ) {
|
||||
while (*p == ' ' || *p == '\t' || *p == ':')
|
||||
while (*p == ' ' || *p == '\t' || *p == ':') {
|
||||
++p;
|
||||
}
|
||||
len = modifier_len(p);
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
p += len;
|
||||
}
|
||||
if ((p[0] == 'w' && p[1] == 'h')
|
||||
|| (p[0] == 'f' && p[1] == 'o' && p[2] == 'r'))
|
||||
|| (p[0] == 'f' && p[1] == 'o' && p[2] == 'r')) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
1210
src/nvim/ex_getln.c
1210
src/nvim/ex_getln.c
File diff suppressed because it is too large
Load Diff
@ -8,13 +8,11 @@
|
||||
// :mksession
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/cursor.h"
|
||||
@ -28,6 +26,7 @@
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/fold.h"
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/keymap.h"
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/move.h"
|
||||
@ -36,6 +35,7 @@
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/os/time.h"
|
||||
#include "nvim/path.h"
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/window.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
@ -63,7 +63,7 @@ static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces)
|
||||
static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
|
||||
{
|
||||
int n = 0;
|
||||
win_T *wp;
|
||||
win_T *wp;
|
||||
|
||||
if (restore_size && (ssop_flags & SSOP_WINSIZE)) {
|
||||
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
@ -105,7 +105,7 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
|
||||
// Returns FAIL when writing the commands to "fd" fails.
|
||||
static int ses_win_rec(FILE *fd, frame_T *fr)
|
||||
{
|
||||
frame_T *frc;
|
||||
frame_T *frc;
|
||||
int count = 0;
|
||||
|
||||
if (fr->fr_layout != FR_LEAF) {
|
||||
@ -149,7 +149,7 @@ static int ses_win_rec(FILE *fd, frame_T *fr)
|
||||
// Returns NULL when there none.
|
||||
static frame_T *ses_skipframe(frame_T *fr)
|
||||
{
|
||||
frame_T *frc;
|
||||
frame_T *frc;
|
||||
|
||||
FOR_ALL_FRAMES(frc, fr) {
|
||||
if (ses_do_frame(frc)) {
|
||||
@ -200,11 +200,10 @@ static int ses_do_win(win_T *wp)
|
||||
/// @param flagp
|
||||
///
|
||||
/// @returns FAIL if writing fails.
|
||||
static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname,
|
||||
unsigned *flagp)
|
||||
static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigned *flagp)
|
||||
{
|
||||
char_u *buf = NULL;
|
||||
char_u *s;
|
||||
char_u *buf = NULL;
|
||||
char_u *s;
|
||||
|
||||
if (fprintf(fd, "%s\n%s\n", cmd, "%argdel") < 0) {
|
||||
return FAIL;
|
||||
@ -297,17 +296,15 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Write commands to "fd" to restore the view of a window.
|
||||
// Caller must make sure 'scrolloff' is zero.
|
||||
static int put_view(
|
||||
FILE *fd,
|
||||
win_T *wp,
|
||||
int add_edit, // add ":edit" command to view
|
||||
unsigned *flagp, // vop_flags or ssop_flags
|
||||
int current_arg_idx // current argument index of the window, use
|
||||
) // -1 if unknown
|
||||
/// Write commands to "fd" to restore the view of a window.
|
||||
/// Caller must make sure 'scrolloff' is zero.
|
||||
///
|
||||
/// @param add_edit add ":edit" command to view
|
||||
/// @param flagp vop_flags or ssop_flags
|
||||
/// @param current_arg_idx current argument index of the window, use -1 if unknown
|
||||
static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int current_arg_idx)
|
||||
{
|
||||
win_T *save_curwin;
|
||||
win_T *save_curwin;
|
||||
int f;
|
||||
int do_cursor;
|
||||
int did_next = false;
|
||||
@ -348,8 +345,8 @@ static int put_view(
|
||||
// Load the file.
|
||||
//
|
||||
if (wp->w_buffer->b_ffname != NULL
|
||||
&& (!bt_nofile(wp->w_buffer) || wp->w_buffer->terminal)
|
||||
) {
|
||||
&& (!bt_nofile(wp->w_buffer) ||
|
||||
wp->w_buffer->terminal)) {
|
||||
// Editing a file in this buffer: use ":edit file".
|
||||
// This may have side effects! (e.g., compressed or network file).
|
||||
//
|
||||
@ -434,8 +431,8 @@ static int put_view(
|
||||
//
|
||||
if ((*flagp & SSOP_FOLDS)
|
||||
&& wp->w_buffer->b_ffname != NULL
|
||||
&& (bt_normal(wp->w_buffer) || bt_help(wp->w_buffer))
|
||||
) {
|
||||
&& (bt_normal(wp->w_buffer) ||
|
||||
bt_help(wp->w_buffer))) {
|
||||
if (put_folds(fd, wp) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
@ -525,12 +522,12 @@ static int makeopens(FILE *fd, char_u *dirnow)
|
||||
int only_save_windows = true;
|
||||
int nr;
|
||||
int restore_size = true;
|
||||
win_T *wp;
|
||||
char_u *sname;
|
||||
win_T *edited_win = NULL;
|
||||
win_T *wp;
|
||||
char_u *sname;
|
||||
win_T *edited_win = NULL;
|
||||
int tabnr;
|
||||
win_T *tab_firstwin;
|
||||
frame_T *tab_topframe;
|
||||
win_T *tab_firstwin;
|
||||
frame_T *tab_topframe;
|
||||
int cur_arg_idx = 0;
|
||||
int next_arg_idx = 0;
|
||||
|
||||
@ -658,8 +655,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
|
||||
if (ses_do_win(wp)
|
||||
&& wp->w_buffer->b_ffname != NULL
|
||||
&& !bt_help(wp->w_buffer)
|
||||
&& !bt_nofile(wp->w_buffer)
|
||||
) {
|
||||
&& !bt_nofile(wp->w_buffer)) {
|
||||
if (need_tabnext && put_line(fd, "tabnext") == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
@ -877,12 +873,12 @@ void ex_loadview(exarg_T *eap)
|
||||
/// - SSOP_SLASH: filenames are written with "/" slash
|
||||
void ex_mkrc(exarg_T *eap)
|
||||
{
|
||||
FILE *fd;
|
||||
FILE *fd;
|
||||
int failed = false;
|
||||
int view_session = false; // :mkview, :mksession
|
||||
int using_vdir = false; // using 'viewdir'?
|
||||
char *viewFile = NULL;
|
||||
unsigned *flagp;
|
||||
unsigned *flagp;
|
||||
|
||||
if (eap->cmdidx == CMD_mksession || eap->cmdidx == CMD_mkview) {
|
||||
view_session = true;
|
||||
|
@ -29,19 +29,20 @@
|
||||
// code for redrawing the line with the deleted decoration.
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "nvim/api/vim.h"
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/buffer_updates.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/lib/kbtree.h"
|
||||
#include "nvim/map.h"
|
||||
#include "nvim/memline.h"
|
||||
#include "nvim/pos.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/map.h"
|
||||
#include "nvim/lib/kbtree.h"
|
||||
#include "nvim/undo.h"
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "extmark.c.generated.h"
|
||||
@ -56,10 +57,9 @@ static ExtmarkNs *buf_ns_ref(buf_T *buf, uint64_t ns_id, bool put) {
|
||||
///
|
||||
/// must not be used during iteration!
|
||||
/// @returns the mark id
|
||||
uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t id,
|
||||
int row, colnr_T col, int end_row, colnr_T end_col,
|
||||
Decoration *decor, bool right_gravity,
|
||||
bool end_right_gravity, ExtmarkOp op)
|
||||
uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t id, int row, colnr_T col, int end_row,
|
||||
colnr_T end_col, Decoration *decor, bool right_gravity, bool end_right_gravity,
|
||||
ExtmarkOp op)
|
||||
{
|
||||
ExtmarkNs *ns = buf_ns_ref(buf, ns_id, true);
|
||||
assert(ns != NULL);
|
||||
@ -178,9 +178,7 @@ bool extmark_del(buf_T *buf, uint64_t ns_id, uint64_t id)
|
||||
|
||||
// Free extmarks in a ns between lines
|
||||
// if ns = 0, it means clear all namespaces
|
||||
bool extmark_clear(buf_T *buf, uint64_t ns_id,
|
||||
int l_row, colnr_T l_col,
|
||||
int u_row, colnr_T u_col)
|
||||
bool extmark_clear(buf_T *buf, uint64_t ns_id, int l_row, colnr_T l_col, int u_row, colnr_T u_col)
|
||||
{
|
||||
if (!map_size(buf->b_extmark_ns)) {
|
||||
return false;
|
||||
@ -281,10 +279,8 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
|
||||
// will be searched to the start, or end
|
||||
// dir can be set to control the order of the array
|
||||
// amount = amount of marks to find or -1 for all
|
||||
ExtmarkInfoArray extmark_get(buf_T *buf, uint64_t ns_id,
|
||||
int l_row, colnr_T l_col,
|
||||
int u_row, colnr_T u_col,
|
||||
int64_t amount, bool reverse)
|
||||
ExtmarkInfoArray extmark_get(buf_T *buf, uint64_t ns_id, int l_row, colnr_T l_col, int u_row,
|
||||
colnr_T u_col, int64_t amount, bool reverse)
|
||||
{
|
||||
ExtmarkInfoArray array = KV_INITIAL_VALUE;
|
||||
MarkTreeIter itr[1];
|
||||
@ -394,10 +390,9 @@ void extmark_free_all(buf_T *buf)
|
||||
|
||||
|
||||
// Save info for undo/redo of set marks
|
||||
static void u_extmark_set(buf_T *buf, uint64_t mark,
|
||||
int row, colnr_T col)
|
||||
static void u_extmark_set(buf_T *buf, uint64_t mark, int row, colnr_T col)
|
||||
{
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
if (!uhp) {
|
||||
return;
|
||||
}
|
||||
@ -419,11 +414,9 @@ static void u_extmark_set(buf_T *buf, uint64_t mark,
|
||||
///
|
||||
/// useful when we cannot simply reverse the operation. This will do nothing on
|
||||
/// redo, enforces correct position when undo.
|
||||
void u_extmark_copy(buf_T *buf,
|
||||
int l_row, colnr_T l_col,
|
||||
int u_row, colnr_T u_col)
|
||||
void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_col)
|
||||
{
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
if (!uhp) {
|
||||
return;
|
||||
}
|
||||
@ -467,7 +460,6 @@ void extmark_apply_undo(ExtmarkUndoObject undo_info, bool undo)
|
||||
splice.new_row, splice.new_col, splice.new_byte,
|
||||
splice.old_row, splice.old_col, splice.old_byte,
|
||||
kExtmarkNoUndo);
|
||||
|
||||
} else {
|
||||
extmark_splice_impl(curbuf,
|
||||
splice.start_row, splice.start_col, splice.start_byte,
|
||||
@ -475,14 +467,14 @@ void extmark_apply_undo(ExtmarkUndoObject undo_info, bool undo)
|
||||
splice.new_row, splice.new_col, splice.new_byte,
|
||||
kExtmarkNoUndo);
|
||||
}
|
||||
// kExtmarkSavePos
|
||||
// kExtmarkSavePos
|
||||
} else if (undo_info.type == kExtmarkSavePos) {
|
||||
ExtmarkSavePos pos = undo_info.data.savepos;
|
||||
if (undo) {
|
||||
if (pos.old_row >= 0) {
|
||||
extmark_setraw(curbuf, pos.mark, pos.old_row, pos.old_col);
|
||||
}
|
||||
// Redo
|
||||
// Redo
|
||||
} else {
|
||||
if (pos.row >= 0) {
|
||||
extmark_setraw(curbuf, pos.mark, pos.row, pos.col);
|
||||
@ -508,11 +500,7 @@ void extmark_apply_undo(ExtmarkUndoObject undo_info, bool undo)
|
||||
|
||||
|
||||
// Adjust extmark row for inserted/deleted rows (columns stay fixed).
|
||||
void extmark_adjust(buf_T *buf,
|
||||
linenr_T line1,
|
||||
linenr_T line2,
|
||||
long amount,
|
||||
long amount_after,
|
||||
void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, long amount_after,
|
||||
ExtmarkOp undo)
|
||||
{
|
||||
if (curbuf_splice_pending) {
|
||||
@ -537,7 +525,7 @@ void extmark_adjust(buf_T *buf,
|
||||
}
|
||||
if (new_row > 0) {
|
||||
new_byte = ml_find_line_or_offset(buf, line1+new_row, NULL, true)
|
||||
- start_byte;
|
||||
- start_byte;
|
||||
}
|
||||
extmark_splice_impl(buf,
|
||||
(int)line1-1, 0, start_byte,
|
||||
@ -562,10 +550,8 @@ void extmark_adjust(buf_T *buf,
|
||||
// the end column of the new region.
|
||||
// @param new_byte Byte extent of the new region.
|
||||
// @param undo
|
||||
void extmark_splice(buf_T *buf,
|
||||
int start_row, colnr_T start_col,
|
||||
int old_row, colnr_T old_col, bcount_t old_byte,
|
||||
int new_row, colnr_T new_col, bcount_t new_byte,
|
||||
void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int old_row, colnr_T old_col,
|
||||
bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte,
|
||||
ExtmarkOp undo)
|
||||
{
|
||||
long offset = ml_find_line_or_offset(buf, start_row + 1, NULL, true);
|
||||
@ -584,11 +570,9 @@ void extmark_splice(buf_T *buf,
|
||||
undo);
|
||||
}
|
||||
|
||||
void extmark_splice_impl(buf_T *buf,
|
||||
int start_row, colnr_T start_col, bcount_t start_byte,
|
||||
int old_row, colnr_T old_col, bcount_t old_byte,
|
||||
int new_row, colnr_T new_col, bcount_t new_byte,
|
||||
ExtmarkOp undo)
|
||||
void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte,
|
||||
int old_row, colnr_T old_col, bcount_t old_byte, int new_row,
|
||||
colnr_T new_col, bcount_t new_byte, ExtmarkOp undo)
|
||||
{
|
||||
curbuf->deleted_bytes2 = 0;
|
||||
buf_updates_send_splice(buf, start_row, start_col, start_byte,
|
||||
@ -612,7 +596,7 @@ void extmark_splice_impl(buf_T *buf,
|
||||
new_row, new_col);
|
||||
|
||||
if (undo == kExtmarkUndo) {
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
if (!uhp) {
|
||||
return;
|
||||
}
|
||||
@ -621,7 +605,7 @@ void extmark_splice_impl(buf_T *buf,
|
||||
// TODO(bfredl): this is quite rudimentary. We merge small (within line)
|
||||
// inserts with each other and small deletes with each other. Add full
|
||||
// merge algorithm later.
|
||||
if (old_row == 0 && new_row == 0 && kv_size(uhp->uh_extmark)) {
|
||||
if (old_row == 0 && new_row == 0 && kv_size(uhp->uh_extmark)) {
|
||||
ExtmarkUndoObject *item = &kv_A(uhp->uh_extmark,
|
||||
kv_size(uhp->uh_extmark)-1);
|
||||
if (item->type == kExtmarkSplice) {
|
||||
@ -669,22 +653,17 @@ void extmark_splice_impl(buf_T *buf,
|
||||
}
|
||||
}
|
||||
|
||||
void extmark_splice_cols(buf_T *buf,
|
||||
int start_row, colnr_T start_col,
|
||||
colnr_T old_col, colnr_T new_col,
|
||||
ExtmarkOp undo)
|
||||
void extmark_splice_cols(buf_T *buf, int start_row, colnr_T start_col, colnr_T old_col,
|
||||
colnr_T new_col, ExtmarkOp undo)
|
||||
{
|
||||
extmark_splice(buf, start_row, start_col,
|
||||
0, old_col, old_col,
|
||||
0, new_col, new_col, undo);
|
||||
}
|
||||
|
||||
void extmark_move_region(
|
||||
buf_T *buf,
|
||||
int start_row, colnr_T start_col, bcount_t start_byte,
|
||||
int extent_row, colnr_T extent_col, bcount_t extent_byte,
|
||||
int new_row, colnr_T new_col, bcount_t new_byte,
|
||||
ExtmarkOp undo)
|
||||
void extmark_move_region(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte,
|
||||
int extent_row, colnr_T extent_col, bcount_t extent_byte, int new_row,
|
||||
colnr_T new_col, bcount_t new_byte, ExtmarkOp undo)
|
||||
{
|
||||
curbuf->deleted_bytes2 = 0;
|
||||
// TODO(bfredl): this is not synced to the buffer state inside the callback.
|
||||
@ -704,7 +683,7 @@ void extmark_move_region(
|
||||
|
||||
|
||||
if (undo == kExtmarkUndo) {
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
if (!uhp) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user