Skip to content

Commit d0807a4

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 60c26e0 + efe0373 commit d0807a4

36 files changed

+1224
-463
lines changed

runtime/doc/options.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,14 @@ A jump table for the options with a short description can be found at |Q_op|.
10591059
name, precede it with a backslash.
10601060
- To include a comma in a directory name precede it with a backslash.
10611061
- A directory name may end in an '/'.
1062+
- For Unix and Win32, if a directory ends in two path separators "//",
1063+
the swap file name will be built from the complete path to the file
1064+
with all path separators changed to percent '%' signs. This will
1065+
ensure file name uniqueness in the backup directory.
1066+
On Win32, it is also possible to end with "\\". However, When a
1067+
separating comma is following, you must use "//", since "\\" will
1068+
include the comma in the file name. Therefore it is recommended to
1069+
use '//', instead of '\\'.
10621070
- Environment variables are expanded |:set_env|.
10631071
- Careful with '\' characters, type one before a space, type two to
10641072
get one in the option (see |option-backslash|), for example: >
@@ -2703,12 +2711,14 @@ A jump table for the options with a short description can be found at |Q_op|.
27032711
- A directory starting with "./" (or ".\" for MS-DOS et al.) means to
27042712
put the swap file relative to where the edited file is. The leading
27052713
"." is replaced with the path name of the edited file.
2706-
- For Unix and Win32, if a directory ends in two path separators "//"
2707-
or "\\", the swap file name will be built from the complete path to
2708-
the file with all path separators substituted to percent '%' signs.
2709-
This will ensure file name uniqueness in the preserve directory.
2710-
On Win32, when a separating comma is following, you must use "//",
2711-
since "\\" will include the comma in the file name.
2714+
- For Unix and Win32, if a directory ends in two path separators "//",
2715+
the swap file name will be built from the complete path to the file
2716+
with all path separators substituted to percent '%' signs. This will
2717+
ensure file name uniqueness in the preserve directory.
2718+
On Win32, it is also possible to end with "\\". However, When a
2719+
separating comma is following, you must use "//", since "\\" will
2720+
include the comma in the file name. Therefore it is recommended to
2721+
use '//', instead of '\\'.
27122722
- Spaces after the comma are ignored, other spaces are considered part
27132723
of the directory name. To have a space at the start of a directory
27142724
name, precede it with a backslash.

runtime/doc/term.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ Added by Vim (there are no standard codes for these):
352352
t_SH set cursor shape *t_SH* *'t_SH'*
353353
t_RC request terminal cursor blinking *t_RC* *'t_RC'*
354354
t_RS request terminal cursor style *t_RS* *'t_RS'*
355+
t_ST save window title to stack *t_ST* *'t_ST'*
356+
t_RT restore window title from stack *t_RT* *'t_RT'*
357+
t_Si save icon text to stack *t_Si* *'t_Si'*
358+
t_Ri restore icon text from stack *t_Ri* *'t_Ri'*
355359

356360
Some codes have a start, middle and end part. The start and end are defined
357361
by the termcap option, the middle part is text.

src/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ NEW_TESTS = \
1212
test_autocmd \
1313
test_autoload \
1414
test_backspace_opt \
15+
test_backup \
1516
test_blockedit \
1617
test_breakindent \
1718
test_bufline \

src/buffer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3808,7 +3808,8 @@ value_changed(char_u *str, char_u **last)
38083808
if (str == NULL)
38093809
{
38103810
*last = NULL;
3811-
mch_restore_title(last == &lasttitle ? 1 : 2);
3811+
mch_restore_title(
3812+
last == &lasttitle ? SAVE_RESTORE_TITLE : SAVE_RESTORE_ICON);
38123813
}
38133814
else
38143815
{

src/channel.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ch_log_active(void)
138138
}
139139

140140
static void
141-
ch_log_lead(const char *what, channel_T *ch)
141+
ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
142142
{
143143
if (log_fd != NULL)
144144
{
@@ -150,7 +150,13 @@ ch_log_lead(const char *what, channel_T *ch)
150150
fprintf(log_fd, "%s ", profile_msg(&log_now));
151151
#endif
152152
if (ch != NULL)
153-
fprintf(log_fd, "%son %d: ", what, ch->ch_id);
153+
{
154+
if (part < PART_COUNT)
155+
fprintf(log_fd, "%son %d(%s): ",
156+
what, ch->ch_id, part_names[part]);
157+
else
158+
fprintf(log_fd, "%son %d: ", what, ch->ch_id);
159+
}
154160
else
155161
fprintf(log_fd, "%s: ", what);
156162
}
@@ -166,7 +172,7 @@ ch_log(channel_T *ch, const char *fmt, ...)
166172
{
167173
va_list ap;
168174

169-
ch_log_lead("", ch);
175+
ch_log_lead("", ch, PART_COUNT);
170176
va_start(ap, fmt);
171177
vfprintf(log_fd, fmt, ap);
172178
va_end(ap);
@@ -191,7 +197,7 @@ ch_error(channel_T *ch, const char *fmt, ...)
191197
{
192198
va_list ap;
193199

194-
ch_log_lead("ERR ", ch);
200+
ch_log_lead("ERR ", ch, PART_COUNT);
195201
va_start(ap, fmt);
196202
vfprintf(log_fd, fmt, ap);
197203
va_end(ap);
@@ -1875,7 +1881,7 @@ channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len,
18751881

18761882
if (ch_log_active() && lead != NULL)
18771883
{
1878-
ch_log_lead(lead, channel);
1884+
ch_log_lead(lead, channel, part);
18791885
fprintf(log_fd, "'");
18801886
ignored = (int)fwrite(buf, len, 1, log_fd);
18811887
fprintf(log_fd, "'\n");
@@ -3760,7 +3766,7 @@ channel_send(
37603766

37613767
if (ch_log_active())
37623768
{
3763-
ch_log_lead("SEND ", channel);
3769+
ch_log_lead("SEND ", channel, part);
37643770
fprintf(log_fd, "'");
37653771
ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd);
37663772
fprintf(log_fd, "'\n");

src/edit.c

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ static colnr_T get_nolist_virtcol(void);
279279
#if defined(FEAT_EVAL)
280280
static char_u *do_insert_char_pre(int c);
281281
#endif
282+
static int ins_apply_autocmds(event_T event);
282283

283284
static colnr_T Insstart_textlen; /* length of line when insert started */
284285
static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */
@@ -411,7 +412,7 @@ edit(
411412
set_vim_var_string(VV_INSERTMODE, ptr, 1);
412413
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
413414
#endif
414-
apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
415+
ins_apply_autocmds(EVENT_INSERTENTER);
415416

416417
/* Make sure the cursor didn't move. Do call check_cursor_col() in
417418
* case the text was modified. Since Insert mode was not started yet
@@ -1061,8 +1062,7 @@ edit(
10611062
if (ins_esc(&count, cmdchar, nomove))
10621063
{
10631064
if (cmdchar != 'r' && cmdchar != 'v')
1064-
apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL,
1065-
FALSE, curbuf);
1065+
ins_apply_autocmds(EVENT_INSERTLEAVE);
10661066
did_cursorhold = FALSE;
10671067
return (c == Ctrl_O);
10681068
}
@@ -1285,7 +1285,7 @@ edit(
12851285
break;
12861286

12871287
case K_CURSORHOLD: /* Didn't type something for a while. */
1288-
apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf);
1288+
ins_apply_autocmds(EVENT_CURSORHOLDI);
12891289
did_cursorhold = TRUE;
12901290
break;
12911291

@@ -1708,7 +1708,7 @@ ins_redraw(
17081708
/* Make sure curswant is correct, an autocommand may call
17091709
* getcurpos(). */
17101710
update_curswant();
1711-
apply_autocmds(EVENT_CURSORMOVEDI, NULL, NULL, FALSE, curbuf);
1711+
ins_apply_autocmds(EVENT_CURSORMOVEDI);
17121712
}
17131713
# ifdef FEAT_CONCEAL
17141714
if (curwin->w_p_cole > 0)
@@ -1731,12 +1731,16 @@ ins_redraw(
17311731
)
17321732
{
17331733
aco_save_T aco;
1734+
varnumber_T tick = CHANGEDTICK(curbuf);
17341735

17351736
// save and restore curwin and curbuf, in case the autocmd changes them
17361737
aucmd_prepbuf(&aco, curbuf);
17371738
apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
17381739
aucmd_restbuf(&aco);
17391740
curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
1741+
if (tick != CHANGEDTICK(curbuf)) // see ins_apply_autocmds()
1742+
u_save(curwin->w_cursor.lnum,
1743+
(linenr_T)(curwin->w_cursor.lnum + 1));
17401744
}
17411745

17421746
#ifdef FEAT_INS_EXPAND
@@ -1748,12 +1752,16 @@ ins_redraw(
17481752
&& pum_visible())
17491753
{
17501754
aco_save_T aco;
1755+
varnumber_T tick = CHANGEDTICK(curbuf);
17511756

17521757
// save and restore curwin and curbuf, in case the autocmd changes them
17531758
aucmd_prepbuf(&aco, curbuf);
17541759
apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf);
17551760
aucmd_restbuf(&aco);
17561761
curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf);
1762+
if (tick != CHANGEDTICK(curbuf)) // see ins_apply_autocmds()
1763+
u_save(curwin->w_cursor.lnum,
1764+
(linenr_T)(curwin->w_cursor.lnum + 1));
17571765
}
17581766
#endif
17591767

@@ -4127,13 +4135,13 @@ ins_compl_prep(int c)
41274135
#endif
41284136
/* Trigger the CompleteDone event to give scripts a chance to act
41294137
* upon the completion. */
4130-
apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf);
4138+
ins_apply_autocmds(EVENT_COMPLETEDONE);
41314139
}
41324140
}
41334141
else if (ctrl_x_mode == CTRL_X_LOCAL_MSG)
41344142
/* Trigger the CompleteDone event to give scripts a chance to act
41354143
* upon the (possibly failed) completion. */
4136-
apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf);
4144+
ins_apply_autocmds(EVENT_COMPLETEDONE);
41374145

41384146
/* reset continue_* if we left expansion-mode, if we stay they'll be
41394147
* (re)set properly in ins_complete() */
@@ -4434,10 +4442,15 @@ ins_compl_get_exp(pos_T *ini)
44344442
? (char_u *)"." : curbuf->b_p_cpt;
44354443
last_match_pos = first_match_pos = *ini;
44364444
}
4445+
else if (ins_buf != curbuf && !buf_valid(ins_buf))
4446+
ins_buf = curbuf; // In case the buffer was wiped out.
44374447

44384448
compl_old_match = compl_curr_match; /* remember the last current match */
44394449
pos = (compl_direction == FORWARD) ? &last_match_pos : &first_match_pos;
4440-
/* For ^N/^P loop over all the flags/windows/buffers in 'complete' */
4450+
4451+
/*
4452+
* For ^N/^P loop over all the flags/windows/buffers in 'complete'.
4453+
*/
44414454
for (;;)
44424455
{
44434456
found_new_match = FAIL;
@@ -8942,7 +8955,7 @@ ins_insert(int replaceState)
89428955
: replaceState == VREPLACE ? "v"
89438956
: "r"), 1);
89448957
# endif
8945-
apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf);
8958+
ins_apply_autocmds(EVENT_INSERTCHANGE);
89468959
if (State & REPLACE_FLAG)
89478960
State = INSERT | (State & LANGMAP);
89488961
else
@@ -10755,7 +10768,7 @@ do_insert_char_pre(int c)
1075510768
set_vim_var_string(VV_CHAR, buf, -1); /* set v:char */
1075610769

1075710770
res = NULL;
10758-
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf))
10771+
if (ins_apply_autocmds(EVENT_INSERTCHARPRE))
1075910772
{
1076010773
/* Get the value of v:char. It may be empty or more than one
1076110774
* character. Only use it when changed, otherwise continue with the
@@ -10770,3 +10783,22 @@ do_insert_char_pre(int c)
1077010783
return res;
1077110784
}
1077210785
#endif
10786+
10787+
/*
10788+
* Trigger "event" and take care of fixing undo.
10789+
*/
10790+
static int
10791+
ins_apply_autocmds(event_T event)
10792+
{
10793+
varnumber_T tick = CHANGEDTICK(curbuf);
10794+
int r;
10795+
10796+
r = apply_autocmds(event, NULL, NULL, FALSE, curbuf);
10797+
10798+
// If u_savesub() was called then we are not prepared to start
10799+
// a new line. Call u_save() with no contents to fix that.
10800+
if (tick != CHANGEDTICK(curbuf))
10801+
u_save(curwin->w_cursor.lnum, (linenr_T)(curwin->w_cursor.lnum + 1));
10802+
10803+
return r;
10804+
}

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5119,7 +5119,7 @@ f_getftype(typval_T *argvars, typval_T *rettv)
51195119
# endif
51205120
# ifdef S_ISSOCK
51215121
else if (S_ISSOCK(st.st_mode))
5122-
t = "fifo";
5122+
t = "socket";
51235123
# endif
51245124
else
51255125
t = "other";

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7766,7 +7766,7 @@ ex_stop(exarg_T *eap)
77667766
stoptermcap();
77677767
out_flush(); /* needed for SUN to restore xterm buffer */
77687768
#ifdef FEAT_TITLE
7769-
mch_restore_title(3); /* restore window titles */
7769+
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
77707770
#endif
77717771
ui_suspend(); /* call machine specific function */
77727772
#ifdef FEAT_TITLE

src/fileio.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,6 +3850,9 @@ buf_write(
38503850
stat_T st_new;
38513851
char_u *dirp;
38523852
char_u *rootname;
3853+
#if defined(UNIX) || defined(WIN3264)
3854+
char_u *p;
3855+
#endif
38533856
#if defined(UNIX)
38543857
int did_set_shortname;
38553858
mode_t umask_save;
@@ -3887,6 +3890,17 @@ buf_write(
38873890
* Isolate one directory name, using an entry in 'bdir'.
38883891
*/
38893892
(void)copy_option_part(&dirp, copybuf, BUFSIZE, ",");
3893+
3894+
#if defined(UNIX) || defined(WIN3264)
3895+
p = copybuf + STRLEN(copybuf);
3896+
if (after_pathsep(copybuf, p) && p[-1] == p[-2])
3897+
// Ends with '//', use full path
3898+
if ((p = make_percent_swname(copybuf, fname)) != NULL)
3899+
{
3900+
backup = modname(p, backup_ext, FALSE);
3901+
vim_free(p);
3902+
}
3903+
#endif
38903904
rootname = get_file_in_dir(fname, copybuf);
38913905
if (rootname == NULL)
38923906
{
@@ -3904,9 +3918,10 @@ buf_write(
39043918
for (;;)
39053919
{
39063920
/*
3907-
* Make backup file name.
3921+
* Make the backup file name.
39083922
*/
3909-
backup = buf_modname((buf->b_p_sn || buf->b_shortname),
3923+
if (backup == NULL)
3924+
backup = buf_modname((buf->b_p_sn || buf->b_shortname),
39103925
rootname, backup_ext, FALSE);
39113926
if (backup == NULL)
39123927
{
@@ -4108,14 +4123,29 @@ buf_write(
41084123
* Isolate one directory name and make the backup file name.
41094124
*/
41104125
(void)copy_option_part(&dirp, IObuff, IOSIZE, ",");
4111-
rootname = get_file_in_dir(fname, IObuff);
4112-
if (rootname == NULL)
4113-
backup = NULL;
4114-
else
4126+
4127+
#if defined(UNIX) || defined(WIN3264)
4128+
p = IObuff + STRLEN(IObuff);
4129+
if (after_pathsep(IObuff, p) && p[-1] == p[-2])
4130+
// path ends with '//', use full path
4131+
if ((p = make_percent_swname(IObuff, fname)) != NULL)
4132+
{
4133+
backup = modname(p, backup_ext, FALSE);
4134+
vim_free(p);
4135+
}
4136+
#endif
4137+
if (backup == NULL)
41154138
{
4116-
backup = buf_modname((buf->b_p_sn || buf->b_shortname),
4117-
rootname, backup_ext, FALSE);
4118-
vim_free(rootname);
4139+
rootname = get_file_in_dir(fname, IObuff);
4140+
if (rootname == NULL)
4141+
backup = NULL;
4142+
else
4143+
{
4144+
backup = buf_modname(
4145+
(buf->b_p_sn || buf->b_shortname),
4146+
rootname, backup_ext, FALSE);
4147+
vim_free(rootname);
4148+
}
41194149
}
41204150

41214151
if (backup != NULL)
@@ -6257,7 +6287,7 @@ shorten_filenames(char_u **fnames, int count)
62576287
#endif
62586288

62596289
/*
6260-
* add extension to file name - change path/fo.o.h to path/fo.o.h.ext or
6290+
* Add extension to file name - change path/fo.o.h to path/fo.o.h.ext or
62616291
* fo_o_h.ext for MSDOS or when shortname option set.
62626292
*
62636293
* Assumed that fname is a valid name found in the filesystem we assure that

0 commit comments

Comments
 (0)