Skip to content

Commit

Permalink
patch 8.2.4001: insert complete code uses global variables
Browse files Browse the repository at this point in the history
Problem:    Insert complete code uses global variables.
Solution:   Make variables local to the file and use accessor functions.
            (Yegappan Lakshmanan, closes #9470)
  • Loading branch information
yegappan authored and brammool committed Jan 4, 2022
1 parent fcd1635 commit d94fbfc
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 163 deletions.
4 changes: 2 additions & 2 deletions src/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ edit(
// but it is under other ^X modes
if (*curbuf->b_p_cpt == NUL
&& (ctrl_x_mode_normal() || ctrl_x_mode_whole_line())
&& !(compl_cont_status & CONT_LOCAL))
&& !compl_status_local())
goto normalchar;

docomplete:
Expand All @@ -1289,7 +1289,7 @@ edit(
disable_fold_update++; // don't redraw folds here
#endif
if (ins_complete(c, TRUE) == FAIL)
compl_cont_status = 0;
compl_status_clear();
#ifdef FEAT_FOLDING
disable_fold_update--;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ handle_mapping(
&& State != ASKMORE
&& State != CONFIRM
&& !((ctrl_x_mode_not_default() && at_ctrl_x_key())
|| ((compl_cont_status & CONT_LOCAL)
|| (compl_status_local()
&& (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P))))
{
#ifdef FEAT_GUI
Expand Down
17 changes: 0 additions & 17 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,6 @@ EXTERN colnr_T dollar_vcol INIT(= -1);
* Variables for Insert mode completion.
*/

// Length in bytes of the text being completed (this is deleted to be replaced
// by the match.)
EXTERN int compl_length INIT(= 0);

// List of flags for method of completion.
EXTERN int compl_cont_status INIT(= 0);
# define CONT_ADDING 1 // "normal" or "adding" expansion
# define CONT_INTRPT (2 + 4) // a ^X interrupted the current expansion
// it's set only iff N_ADDS is set
# define CONT_N_ADDS 4 // next ^X<> will add-new or expand-current
# define CONT_S_IPOS 8 // next ^X<> will set initial_pos?
// if so, word-wise-expansion will set SOL
# define CONT_SOL 16 // pattern includes start of line, just for
// word-wise expansion, not set for ^X^L
# define CONT_LOCAL 32 // for ctrl_x_mode 0, ^X^P/^X^N do a local
// expansion, (eg use complete=.)

EXTERN char_u *edit_submode INIT(= NULL); // msg for CTRL-X submode
EXTERN char_u *edit_submode_pre INIT(= NULL); // prepended to edit_submode
EXTERN char_u *edit_submode_extra INIT(= NULL);// appended to edit_submode
Expand Down

0 comments on commit d94fbfc

Please sign in to comment.