0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.1.2047: cannot check the current state

Problem:    Cannot check the current state.
Solution:   Add the state() function.
This commit is contained in:
Bram Moolenaar
2019-09-16 22:56:03 +02:00
parent 69198cb8c0
commit 0e57dd859e
12 changed files with 230 additions and 111 deletions

View File

@@ -1031,20 +1031,21 @@ is_not_a_term()
// When TRUE in a safe state when starting to wait for a character.
static int was_safe = FALSE;
static oparg_T *current_oap = NULL;
/*
* Trigger SafeState if currently in a safe state for main_loop().
* Return TRUE if an operator was started but not finished yet.
* Includes typing a count or a register name.
*/
static void
may_trigger_safestate_main(oparg_T *oap)
int
op_pending(void)
{
may_trigger_safestate(
!finish_op
&& oap->prev_opcount > 0
&& oap->prev_count0 == 0
&& oap->op_type == OP_NOP
&& oap->regname == NUL
&& restart_edit == 0);
return !(current_oap != NULL
&& !finish_op
&& current_oap->prev_opcount == 0
&& current_oap->prev_count0 == 0
&& current_oap->op_type == OP_NOP
&& current_oap->regname == NUL);
}
/*
@@ -1100,15 +1101,19 @@ main_loop(
int cmdwin, /* TRUE when working in the command-line window */
int noexmode) /* TRUE when return on entering Ex mode */
{
oparg_T oa; /* operator arguments */
volatile int previous_got_int = FALSE; /* "got_int" was TRUE */
oparg_T oa; // operator arguments
oparg_T *prev_oap; // operator arguments
volatile int previous_got_int = FALSE; // "got_int" was TRUE
#ifdef FEAT_CONCEAL
/* these are static to avoid a compiler warning */
// these are static to avoid a compiler warning
static linenr_T conceal_old_cursor_line = 0;
static linenr_T conceal_new_cursor_line = 0;
static int conceal_update_lines = FALSE;
#endif
prev_oap = current_oap;
current_oap = &oa;
#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
/* Setup to catch a terminating error from the X server. Just ignore
* it, restore the state and continue. This might not always work
@@ -1276,7 +1281,7 @@ main_loop(
// If nothing is pending and we are going to wait for the user to
// type a character, trigger SafeState.
may_trigger_safestate_main(&oa);
may_trigger_safestate(!op_pending() && restart_edit == 0);
#if defined(FEAT_DIFF)
// Updating diffs from changed() does not always work properly,
@@ -1430,7 +1435,7 @@ main_loop(
if (exmode_active)
{
if (noexmode) /* End of ":global/path/visual" commands */
return;
goto theend;
do_exmode(exmode_active == EXMODE_VIM);
}
else
@@ -1457,6 +1462,9 @@ main_loop(
}
}
}
theend:
current_oap = prev_oap;
}