Skip to content

Commit 43fb579

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 4f0f018 + 462455e commit 43fb579

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/fileio.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7688,6 +7688,8 @@ forward_slash(char_u *fname)
76887688
* together, to avoid having to match the pattern too often.
76897689
* The result is an array of Autopat lists, which point to AutoCmd lists:
76907690
*
7691+
* last_autopat[0] -----------------------------+
7692+
* V
76917693
* first_autopat[0] --> Autopat.next --> Autopat.next --> NULL
76927694
* Autopat.cmds Autopat.cmds
76937695
* | |
@@ -7700,6 +7702,8 @@ forward_slash(char_u *fname)
77007702
* V
77017703
* NULL
77027704
*
7705+
* last_autopat[1] --------+
7706+
* V
77037707
* first_autopat[1] --> Autopat.next --> NULL
77047708
* Autopat.cmds
77057709
* |
@@ -7727,11 +7731,12 @@ typedef struct AutoCmd
77277731

77287732
typedef struct AutoPat
77297733
{
7734+
struct AutoPat *next; /* next AutoPat in AutoPat list; MUST
7735+
* be the first entry */
77307736
char_u *pat; /* pattern as typed (NULL when pattern
77317737
has been removed) */
77327738
regprog_T *reg_prog; /* compiled regprog for pattern */
77337739
AutoCmd *cmds; /* list of commands to do */
7734-
struct AutoPat *next; /* next AutoPat in AutoPat list */
77357740
int group; /* group ID */
77367741
int patlen; /* strlen() of pat */
77377742
int buflocal_nr; /* !=0 for buffer-local AutoPat */
@@ -7851,6 +7856,16 @@ static AutoPat *first_autopat[NUM_EVENTS] =
78517856
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
78527857
};
78537858

7859+
static AutoPat *last_autopat[NUM_EVENTS] =
7860+
{
7861+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
7862+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
7863+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
7864+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
7865+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
7866+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
7867+
};
7868+
78547869
/*
78557870
* struct used to keep status while executing autocommands for an event.
78567871
*/
@@ -8049,6 +8064,15 @@ au_cleanup(void)
80498064
/* remove the pattern if it has been marked for deletion */
80508065
if (ap->pat == NULL)
80518066
{
8067+
if (ap->next == NULL)
8068+
{
8069+
if (prev_ap == &(first_autopat[(int)event]))
8070+
last_autopat[(int)event] = NULL;
8071+
else
8072+
/* this depends on the "next" field being the first in
8073+
* the struct */
8074+
last_autopat[(int)event] = (AutoPat *)prev_ap;
8075+
}
80528076
*prev_ap = ap->next;
80538077
vim_regfree(ap->reg_prog);
80548078
vim_free(ap);
@@ -8713,9 +8737,13 @@ do_autocmd_event(
87138737
}
87148738

87158739
/*
8716-
* Find AutoPat entries with this pattern.
8740+
* Find AutoPat entries with this pattern. When adding a command it
8741+
* always goes at or after the last one, so start at the end.
87178742
*/
8718-
prev_ap = &first_autopat[(int)event];
8743+
if (!forceit && *cmd != NUL && last_autopat[(int)event] != NULL)
8744+
prev_ap = &last_autopat[(int)event];
8745+
else
8746+
prev_ap = &first_autopat[(int)event];
87198747
while ((ap = *prev_ap) != NULL)
87208748
{
87218749
if (ap->pat != NULL)
@@ -8821,6 +8849,7 @@ do_autocmd_event(
88218849
}
88228850
ap->cmds = NULL;
88238851
*prev_ap = ap;
8852+
last_autopat[(int)event] = ap;
88248853
ap->next = NULL;
88258854
if (group == AUGROUP_ALL)
88268855
ap->group = current_augroup;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ static char *(features[]) =
776776

777777
static int included_patches[] =
778778
{ /* Add new patch number below this line */
779+
/**/
780+
1284,
779781
/**/
780782
1283,
781783
/**/

0 commit comments

Comments
 (0)