Merge remote-tracking branch 'vim/master'

This commit is contained in:
Kazuki Sakamoto
2018-08-09 20:38:52 -07:00
36 changed files with 1225 additions and 464 deletions
+16 -6
View File
@@ -1059,6 +1059,14 @@ A jump table for the options with a short description can be found at |Q_op|.
name, precede it with a backslash.
- To include a comma in a directory name precede it with a backslash.
- A directory name may end in an '/'.
- For Unix and Win32, if a directory ends in two path separators "//",
the swap file name will be built from the complete path to the file
with all path separators changed to percent '%' signs. This will
ensure file name uniqueness in the backup directory.
On Win32, it is also possible to end with "\\". However, When a
separating comma is following, you must use "//", since "\\" will
include the comma in the file name. Therefore it is recommended to
use '//', instead of '\\'.
- Environment variables are expanded |:set_env|.
- Careful with '\' characters, type one before a space, type two to
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|.
- A directory starting with "./" (or ".\" for MS-DOS et al.) means to
put the swap file relative to where the edited file is. The leading
"." is replaced with the path name of the edited file.
- For Unix and Win32, if a directory ends in two path separators "//"
or "\\", the swap file name will be built from the complete path to
the file with all path separators substituted to percent '%' signs.
This will ensure file name uniqueness in the preserve directory.
On Win32, when a separating comma is following, you must use "//",
since "\\" will include the comma in the file name.
- For Unix and Win32, if a directory ends in two path separators "//",
the swap file name will be built from the complete path to the file
with all path separators substituted to percent '%' signs. This will
ensure file name uniqueness in the preserve directory.
On Win32, it is also possible to end with "\\". However, When a
separating comma is following, you must use "//", since "\\" will
include the comma in the file name. Therefore it is recommended to
use '//', instead of '\\'.
- Spaces after the comma are ignored, other spaces are considered part
of the directory name. To have a space at the start of a directory
name, precede it with a backslash.
+4
View File
@@ -352,6 +352,10 @@ Added by Vim (there are no standard codes for these):
t_SH set cursor shape *t_SH* *'t_SH'*
t_RC request terminal cursor blinking *t_RC* *'t_RC'*
t_RS request terminal cursor style *t_RS* *'t_RS'*
t_ST save window title to stack *t_ST* *'t_ST'*
t_RT restore window title from stack *t_RT* *'t_RT'*
t_Si save icon text to stack *t_Si* *'t_Si'*
t_Ri restore icon text from stack *t_Ri* *'t_Ri'*
Some codes have a start, middle and end part. The start and end are defined
by the termcap option, the middle part is text.
+1
View File
@@ -12,6 +12,7 @@ NEW_TESTS = \
test_autocmd \
test_autoload \
test_backspace_opt \
test_backup \
test_blockedit \
test_breakindent \
test_bufline \
+2 -1
View File
@@ -3808,7 +3808,8 @@ value_changed(char_u *str, char_u **last)
if (str == NULL)
{
*last = NULL;
mch_restore_title(last == &lasttitle ? 1 : 2);
mch_restore_title(
last == &lasttitle ? SAVE_RESTORE_TITLE : SAVE_RESTORE_ICON);
}
else
{
+12 -6
View File
@@ -138,7 +138,7 @@ ch_log_active(void)
}
static void
ch_log_lead(const char *what, channel_T *ch)
ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
{
if (log_fd != NULL)
{
@@ -150,7 +150,13 @@ ch_log_lead(const char *what, channel_T *ch)
fprintf(log_fd, "%s ", profile_msg(&log_now));
#endif
if (ch != NULL)
fprintf(log_fd, "%son %d: ", what, ch->ch_id);
{
if (part < PART_COUNT)
fprintf(log_fd, "%son %d(%s): ",
what, ch->ch_id, part_names[part]);
else
fprintf(log_fd, "%son %d: ", what, ch->ch_id);
}
else
fprintf(log_fd, "%s: ", what);
}
@@ -166,7 +172,7 @@ ch_log(channel_T *ch, const char *fmt, ...)
{
va_list ap;
ch_log_lead("", ch);
ch_log_lead("", ch, PART_COUNT);
va_start(ap, fmt);
vfprintf(log_fd, fmt, ap);
va_end(ap);
@@ -191,7 +197,7 @@ ch_error(channel_T *ch, const char *fmt, ...)
{
va_list ap;
ch_log_lead("ERR ", ch);
ch_log_lead("ERR ", ch, PART_COUNT);
va_start(ap, fmt);
vfprintf(log_fd, fmt, ap);
va_end(ap);
@@ -1875,7 +1881,7 @@ channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len,
if (ch_log_active() && lead != NULL)
{
ch_log_lead(lead, channel);
ch_log_lead(lead, channel, part);
fprintf(log_fd, "'");
ignored = (int)fwrite(buf, len, 1, log_fd);
fprintf(log_fd, "'\n");
@@ -3760,7 +3766,7 @@ channel_send(
if (ch_log_active())
{
ch_log_lead("SEND ", channel);
ch_log_lead("SEND ", channel, part);
fprintf(log_fd, "'");
ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd);
fprintf(log_fd, "'\n");
+42 -10
View File
@@ -279,6 +279,7 @@ static colnr_T get_nolist_virtcol(void);
#if defined(FEAT_EVAL)
static char_u *do_insert_char_pre(int c);
#endif
static int ins_apply_autocmds(event_T event);
static colnr_T Insstart_textlen; /* length of line when insert started */
static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */
@@ -411,7 +412,7 @@ edit(
set_vim_var_string(VV_INSERTMODE, ptr, 1);
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
#endif
apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
ins_apply_autocmds(EVENT_INSERTENTER);
/* Make sure the cursor didn't move. Do call check_cursor_col() in
* case the text was modified. Since Insert mode was not started yet
@@ -1061,8 +1062,7 @@ doESCkey:
if (ins_esc(&count, cmdchar, nomove))
{
if (cmdchar != 'r' && cmdchar != 'v')
apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL,
FALSE, curbuf);
ins_apply_autocmds(EVENT_INSERTLEAVE);
did_cursorhold = FALSE;
return (c == Ctrl_O);
}
@@ -1285,7 +1285,7 @@ doESCkey:
break;
case K_CURSORHOLD: /* Didn't type something for a while. */
apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf);
ins_apply_autocmds(EVENT_CURSORHOLDI);
did_cursorhold = TRUE;
break;
@@ -1708,7 +1708,7 @@ ins_redraw(
/* Make sure curswant is correct, an autocommand may call
* getcurpos(). */
update_curswant();
apply_autocmds(EVENT_CURSORMOVEDI, NULL, NULL, FALSE, curbuf);
ins_apply_autocmds(EVENT_CURSORMOVEDI);
}
# ifdef FEAT_CONCEAL
if (curwin->w_p_cole > 0)
@@ -1731,12 +1731,16 @@ ins_redraw(
)
{
aco_save_T aco;
varnumber_T tick = CHANGEDTICK(curbuf);
// save and restore curwin and curbuf, in case the autocmd changes them
aucmd_prepbuf(&aco, curbuf);
apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
aucmd_restbuf(&aco);
curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
if (tick != CHANGEDTICK(curbuf)) // see ins_apply_autocmds()
u_save(curwin->w_cursor.lnum,
(linenr_T)(curwin->w_cursor.lnum + 1));
}
#ifdef FEAT_INS_EXPAND
@@ -1748,12 +1752,16 @@ ins_redraw(
&& pum_visible())
{
aco_save_T aco;
varnumber_T tick = CHANGEDTICK(curbuf);
// save and restore curwin and curbuf, in case the autocmd changes them
aucmd_prepbuf(&aco, curbuf);
apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf);
aucmd_restbuf(&aco);
curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf);
if (tick != CHANGEDTICK(curbuf)) // see ins_apply_autocmds()
u_save(curwin->w_cursor.lnum,
(linenr_T)(curwin->w_cursor.lnum + 1));
}
#endif
@@ -4127,13 +4135,13 @@ ins_compl_prep(int c)
#endif
/* Trigger the CompleteDone event to give scripts a chance to act
* upon the completion. */
apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf);
ins_apply_autocmds(EVENT_COMPLETEDONE);
}
}
else if (ctrl_x_mode == CTRL_X_LOCAL_MSG)
/* Trigger the CompleteDone event to give scripts a chance to act
* upon the (possibly failed) completion. */
apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf);
ins_apply_autocmds(EVENT_COMPLETEDONE);
/* reset continue_* if we left expansion-mode, if we stay they'll be
* (re)set properly in ins_complete() */
@@ -4434,10 +4442,15 @@ ins_compl_get_exp(pos_T *ini)
? (char_u *)"." : curbuf->b_p_cpt;
last_match_pos = first_match_pos = *ini;
}
else if (ins_buf != curbuf && !buf_valid(ins_buf))
ins_buf = curbuf; // In case the buffer was wiped out.
compl_old_match = compl_curr_match; /* remember the last current match */
pos = (compl_direction == FORWARD) ? &last_match_pos : &first_match_pos;
/* For ^N/^P loop over all the flags/windows/buffers in 'complete' */
/*
* For ^N/^P loop over all the flags/windows/buffers in 'complete'.
*/
for (;;)
{
found_new_match = FAIL;
@@ -8942,7 +8955,7 @@ ins_insert(int replaceState)
: replaceState == VREPLACE ? "v"
: "r"), 1);
# endif
apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf);
ins_apply_autocmds(EVENT_INSERTCHANGE);
if (State & REPLACE_FLAG)
State = INSERT | (State & LANGMAP);
else
@@ -10755,7 +10768,7 @@ do_insert_char_pre(int c)
set_vim_var_string(VV_CHAR, buf, -1); /* set v:char */
res = NULL;
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf))
if (ins_apply_autocmds(EVENT_INSERTCHARPRE))
{
/* Get the value of v:char. It may be empty or more than one
* character. Only use it when changed, otherwise continue with the
@@ -10770,3 +10783,22 @@ do_insert_char_pre(int c)
return res;
}
#endif
/*
* Trigger "event" and take care of fixing undo.
*/
static int
ins_apply_autocmds(event_T event)
{
varnumber_T tick = CHANGEDTICK(curbuf);
int r;
r = apply_autocmds(event, NULL, NULL, FALSE, curbuf);
// If u_savesub() was called then we are not prepared to start
// a new line. Call u_save() with no contents to fix that.
if (tick != CHANGEDTICK(curbuf))
u_save(curwin->w_cursor.lnum, (linenr_T)(curwin->w_cursor.lnum + 1));
return r;
}
+1 -1
View File
@@ -5119,7 +5119,7 @@ f_getftype(typval_T *argvars, typval_T *rettv)
# endif
# ifdef S_ISSOCK
else if (S_ISSOCK(st.st_mode))
t = "fifo";
t = "socket";
# endif
else
t = "other";
+1 -1
View File
@@ -7766,7 +7766,7 @@ ex_stop(exarg_T *eap)
stoptermcap();
out_flush(); /* needed for SUN to restore xterm buffer */
#ifdef FEAT_TITLE
mch_restore_title(3); /* restore window titles */
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
#endif
ui_suspend(); /* call machine specific function */
#ifdef FEAT_TITLE
+40 -10
View File
@@ -3850,6 +3850,9 @@ buf_write(
stat_T st_new;
char_u *dirp;
char_u *rootname;
#if defined(UNIX) || defined(WIN3264)
char_u *p;
#endif
#if defined(UNIX)
int did_set_shortname;
mode_t umask_save;
@@ -3887,6 +3890,17 @@ buf_write(
* Isolate one directory name, using an entry in 'bdir'.
*/
(void)copy_option_part(&dirp, copybuf, BUFSIZE, ",");
#if defined(UNIX) || defined(WIN3264)
p = copybuf + STRLEN(copybuf);
if (after_pathsep(copybuf, p) && p[-1] == p[-2])
// Ends with '//', use full path
if ((p = make_percent_swname(copybuf, fname)) != NULL)
{
backup = modname(p, backup_ext, FALSE);
vim_free(p);
}
#endif
rootname = get_file_in_dir(fname, copybuf);
if (rootname == NULL)
{
@@ -3904,9 +3918,10 @@ buf_write(
for (;;)
{
/*
* Make backup file name.
* Make the backup file name.
*/
backup = buf_modname((buf->b_p_sn || buf->b_shortname),
if (backup == NULL)
backup = buf_modname((buf->b_p_sn || buf->b_shortname),
rootname, backup_ext, FALSE);
if (backup == NULL)
{
@@ -4108,14 +4123,29 @@ buf_write(
* Isolate one directory name and make the backup file name.
*/
(void)copy_option_part(&dirp, IObuff, IOSIZE, ",");
rootname = get_file_in_dir(fname, IObuff);
if (rootname == NULL)
backup = NULL;
else
#if defined(UNIX) || defined(WIN3264)
p = IObuff + STRLEN(IObuff);
if (after_pathsep(IObuff, p) && p[-1] == p[-2])
// path ends with '//', use full path
if ((p = make_percent_swname(IObuff, fname)) != NULL)
{
backup = modname(p, backup_ext, FALSE);
vim_free(p);
}
#endif
if (backup == NULL)
{
backup = buf_modname((buf->b_p_sn || buf->b_shortname),
rootname, backup_ext, FALSE);
vim_free(rootname);
rootname = get_file_in_dir(fname, IObuff);
if (rootname == NULL)
backup = NULL;
else
{
backup = buf_modname(
(buf->b_p_sn || buf->b_shortname),
rootname, backup_ext, FALSE);
vim_free(rootname);
}
}
if (backup != NULL)
@@ -6257,7 +6287,7 @@ shorten_filenames(char_u **fnames, int count)
#endif
/*
* add extension to file name - change path/fo.o.h to path/fo.o.h.ext or
* Add extension to file name - change path/fo.o.h to path/fo.o.h.ext or
* fo_o_h.ext for MSDOS or when shortname option set.
*
* Assumed that fname is a valid name found in the filesystem we assure that
+32
View File
@@ -788,6 +788,29 @@ property_event(GtkWidget *widget,
}
#endif /* defined(FEAT_CLIENTSERVER) */
/*
* Handle changes to the "Xft/DPI" setting
*/
static void
gtk_settings_xft_dpi_changed_cb(GtkSettings *gtk_settings UNUSED,
GParamSpec *pspec UNUSED,
gpointer data UNUSED)
{
// Create a new PangoContext for this screen, and initialize it
// with the current font if necessary.
if (gui.text_context != NULL)
g_object_unref(gui.text_context);
gui.text_context = gtk_widget_create_pango_context(gui.mainwin);
pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR);
if (gui.norm_font != NULL)
{
// force default font
gui_mch_init_font(*p_guifont == NUL ? NULL : p_guifont, FALSE);
gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH);
}
}
#if GTK_CHECK_VERSION(3,0,0)
typedef gboolean timeout_cb_type;
@@ -4383,6 +4406,15 @@ gui_mch_init(void)
/* Pretend we don't have input focus, we will get an event if we do. */
gui.in_focus = FALSE;
// Handle changes to the "Xft/DPI" setting.
{
GtkSettings *gtk_settings =
gtk_settings_get_for_screen(gdk_screen_get_default());
g_signal_connect(gtk_settings, "notify::gtk-xft-dpi",
G_CALLBACK(gtk_settings_xft_dpi_changed_cb), NULL);
}
return OK;
}
+60 -29
View File
@@ -544,27 +544,57 @@ PythonIO_Init_io(void)
}
#if PY_VERSION_HEX < 0x030700f0
static PyObject *call_load_module(char *name, int len, PyObject *find_module_result);
typedef struct
{
PyObject_HEAD
PyObject *module;
char *fullname;
PyObject *result;
} LoaderObject;
static PyTypeObject LoaderType;
static void
LoaderDestructor(LoaderObject *self)
{
Py_DECREF(self->module);
vim_free(self->fullname);
Py_XDECREF(self->result);
DESTRUCTOR_FINISH(self);
}
static PyObject *
LoaderLoadModule(LoaderObject *self, PyObject *args UNUSED)
{
PyObject *ret = self->module;
char *fullname = self->fullname;
PyObject *result = self->result;
PyObject *module;
Py_INCREF(ret);
return ret;
if (!fullname)
{
module = result ? result : Py_None;
Py_INCREF(module);
return module;
}
module = call_load_module(fullname, (int)STRLEN(fullname), result);
self->fullname = NULL;
self->result = module;
vim_free(fullname);
Py_DECREF(result);
if (!module)
{
if (PyErr_Occurred())
return NULL;
Py_INCREF(Py_None);
return Py_None;
}
Py_INCREF(module);
return module;
}
static struct PyMethodDef LoaderMethods[] = {
@@ -1252,7 +1282,11 @@ find_module(char *fullname, char *tail, PyObject *new_path)
if (!(find_module_result = PyObject_CallFunction(py_find_module,
"s#O", tail, partlen, new_path)))
{
if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_ImportError))
PyErr_Clear();
return NULL;
}
if (!(module = call_load_module(
fullname,
@@ -1273,30 +1307,23 @@ find_module(char *fullname, char *tail, PyObject *new_path)
Py_DECREF(module);
module = find_module(fullname, dot + 1, newest_path);
find_module_result = find_module(fullname, dot + 1, newest_path);
Py_DECREF(newest_path);
return module;
return find_module_result;
}
else
{
if (!(find_module_result = PyObject_CallFunction(py_find_module,
"sO", tail, new_path)))
return NULL;
if (!(module = call_load_module(
fullname,
(int)STRLEN(fullname),
find_module_result)))
{
Py_DECREF(find_module_result);
if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_ImportError))
PyErr_Clear();
return NULL;
}
Py_DECREF(find_module_result);
return module;
return find_module_result;
}
}
@@ -1304,7 +1331,7 @@ find_module(char *fullname, char *tail, PyObject *new_path)
FinderFindModule(PyObject *self, PyObject *args)
{
char *fullname;
PyObject *module;
PyObject *result;
PyObject *new_path;
LoaderObject *loader;
@@ -1314,31 +1341,35 @@ FinderFindModule(PyObject *self, PyObject *args)
if (!(new_path = Vim_GetPaths(self)))
return NULL;
module = find_module(fullname, fullname, new_path);
result = find_module(fullname, fullname, new_path);
Py_DECREF(new_path);
if (!module)
if (!result)
{
if (PyErr_Occurred())
{
if (PyErr_ExceptionMatches(PyExc_ImportError))
PyErr_Clear();
else
return NULL;
}
return NULL;
Py_INCREF(Py_None);
return Py_None;
}
if (!(loader = PyObject_NEW(LoaderObject, &LoaderType)))
if (!(fullname = (char *)vim_strsave((char_u *)fullname)))
{
Py_DECREF(module);
Py_DECREF(result);
PyErr_NoMemory();
return NULL;
}
loader->module = module;
if (!(loader = PyObject_NEW(LoaderObject, &LoaderType)))
{
vim_free(fullname);
Py_DECREF(result);
return NULL;
}
loader->fullname = fullname;
loader->result = result;
return (PyObject *) loader;
}
+4
View File
@@ -729,6 +729,10 @@ vim_main2(void)
scroll_region_reset(); /* In case Rows changed */
scroll_start(); /* may scroll the screen to the right position */
#if defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) || defined(MACOS_X))
term_push_title(SAVE_RESTORE_BOTH);
#endif
/*
* Don't clear the screen when starting in Ex mode, unless using the GUI.
*/
+5 -10
View File
@@ -262,9 +262,6 @@ static int fnamecmp_ino(char_u *, char_u *, long);
#endif
static void long_to_char(long, char_u *);
static long char_to_long(char_u *);
#if defined(UNIX) || defined(WIN3264)
static char_u *make_percent_swname(char_u *dir, char_u *name);
#endif
#ifdef FEAT_CRYPT
static cryptstate_T *ml_crypt_prepare(memfile_T *mfp, off_T offset, int reading);
#endif
@@ -2007,18 +2004,18 @@ recover_names(
return file_count;
}
#if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */
#if defined(UNIX) || defined(WIN3264) || defined(PROTO)
/*
* Need _very_ long file names.
* Append the full path to name with path separators made into percent
* signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
*/
static char_u *
char_u *
make_percent_swname(char_u *dir, char_u *name)
{
char_u *d, *s, *f;
char_u *d = NULL, *s, *f;
f = fix_fname(name != NULL ? name : (char_u *) "");
d = NULL;
f = fix_fname(name != NULL ? name : (char_u *)"");
if (f != NULL)
{
s = alloc((unsigned)(STRLEN(f) + 1));
@@ -4070,8 +4067,6 @@ attention_message(
}
#if defined(FEAT_EVAL)
static int do_swapexists(buf_T *buf, char_u *fname);
/*
* Trigger the SwapExists autocommands.
* Returns a value for equivalent to do_dialog() (see below):
+7 -3
View File
@@ -3275,7 +3275,9 @@ static struct vimoption options[] =
p_term("t_RB", T_RBG)
p_term("t_RC", T_CRC)
p_term("t_RI", T_CRI)
p_term("t_Ri", T_SRI)
p_term("t_RS", T_CRS)
p_term("t_RT", T_CRT)
p_term("t_RV", T_CRV)
p_term("t_Sb", T_CSB)
p_term("t_SC", T_CSC)
@@ -3283,9 +3285,11 @@ static struct vimoption options[] =
p_term("t_Sf", T_CSF)
p_term("t_SH", T_CSH)
p_term("t_SI", T_CSI)
p_term("t_Si", T_SSI)
p_term("t_so", T_SO)
p_term("t_SR", T_CSR)
p_term("t_sr", T_SR)
p_term("t_ST", T_CST)
p_term("t_Te", T_STE)
p_term("t_te", T_TE)
p_term("t_ti", T_TI)
@@ -10624,7 +10628,7 @@ clear_termoptions(void)
mch_setmouse(FALSE); /* switch mouse off */
#endif
#ifdef FEAT_TITLE
mch_restore_title(3); /* restore window titles */
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
#endif
#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
/* When starting the GUI close the display opened for the clipboard.
@@ -11432,8 +11436,8 @@ buf_copy_options(buf_T *buf, int flags)
buf->b_p_isk = NULL;
}
/*
* Always free the allocated strings.
* If not already initialized, set 'readonly' and copy 'fileformat'.
* Always free the allocated strings. If not already initialized,
* reset 'readonly' and copy 'fileformat'.
*/
if (!buf->b_p_initialized)
{
+5 -5
View File
@@ -617,14 +617,14 @@ mch_settitle(char_u *title, char_u *icon)
/*
* Restore the window/icon title.
* which is one of:
* 1 Just restore title
* 2 Just restore icon (which we don't have)
* 3 Restore title and icon (which we don't have)
* SAVE_RESTORE_TITLE Just restore title
* SAVE_RESTORE_ICON Just restore icon (which we don't have)
* SAVE_RESTORE_BOTH Restore title and icon (which we don't have)
*/
void
mch_restore_title(int which)
{
if (which & 1)
if (which & SAVE_RESTORE_TITLE)
mch_settitle(oldwindowtitle, NULL);
}
@@ -907,7 +907,7 @@ mch_exit(int r)
}
#ifdef FEAT_TITLE
mch_restore_title(3); /* restore window title */
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window title */
#endif
ml_close_all(TRUE); /* remove all memfiles */
+3 -3
View File
@@ -304,9 +304,9 @@ mch_settitle(
/*
* Restore the window/icon title.
* which is one of:
* 1: Just restore title
* 2: Just restore icon (which we don't have)
* 3: Restore title and icon (which we don't have)
* SAVE_RESTORE_TITLE: Just restore title
* SAVE_RESTORE_ICON: Just restore icon (which we don't have)
* SAVE_RESTORE_BOTH: Restore title and icon (which we don't have)
*/
void
mch_restore_title(int which UNUSED)
+67 -19
View File
@@ -1227,7 +1227,23 @@ deathtrap SIGDEFARG(sigarg)
SIGRETURN;
}
#if defined(_REENTRANT) && defined(SIGCONT)
static void
after_sigcont(void)
{
# ifdef FEAT_TITLE
// Set oldtitle to NULL, so the current title is obtained again.
VIM_CLEAR(oldtitle);
# endif
settmode(TMODE_RAW);
need_check_timestamps = TRUE;
did_check_timestamps = FALSE;
}
#if defined(SIGCONT)
static RETSIGTYPE sigcont_handler SIGPROTOARG;
static int in_mch_suspend = FALSE;
# if defined(_REENTRANT) && defined(SIGCONT)
/*
* On Solaris with multi-threading, suspending might not work immediately.
* Catch the SIGCONT signal, which will be used as an indication whether the
@@ -1239,7 +1255,7 @@ deathtrap SIGDEFARG(sigarg)
* volatile because it is used in signal handler sigcont_handler().
*/
static volatile int sigcont_received;
static RETSIGTYPE sigcont_handler SIGPROTOARG;
# endif
/*
* signal handler for SIGCONT
@@ -1247,7 +1263,38 @@ static RETSIGTYPE sigcont_handler SIGPROTOARG;
static RETSIGTYPE
sigcont_handler SIGDEFARG(sigarg)
{
sigcont_received = TRUE;
if (in_mch_suspend)
{
# if defined(_REENTRANT) && defined(SIGCONT)
sigcont_received = TRUE;
# endif
}
else
{
// We didn't suspend ourselves, assume we were stopped by a SIGSTOP
// signal (which can't be intercepted) and get a SIGCONT. Need to get
// back to a sane mode and redraw.
after_sigcont();
update_screen(CLEAR);
if (State & CMDLINE)
redrawcmdline();
else if (State == HITRETURN || State == SETWSIZE || State == ASKMORE
|| State == EXTERNCMD || State == CONFIRM || exmode_active)
repeat_message();
else if (redrawing())
setcursor();
#if defined(FEAT_INS_EXPAND)
if (pum_visible())
{
redraw_later(NOT_VALID);
ins_compl_show_pum();
}
#endif
cursor_on_force();
out_flush();
}
SIGRETURN;
}
#endif
@@ -1330,6 +1377,8 @@ mch_suspend(void)
{
/* BeOS does have SIGTSTP, but it doesn't work. */
#if defined(SIGTSTP) && !defined(__BEOS__)
in_mch_suspend = TRUE;
out_flush(); /* needed to make cursor visible on some systems */
settmode(TMODE_COOK);
out_flush(); /* needed to disable mouse on some systems */
@@ -1361,16 +1410,9 @@ mch_suspend(void)
mch_delay(wait_time, FALSE);
}
# endif
in_mch_suspend = FALSE;
# ifdef FEAT_TITLE
/*
* Set oldtitle to NULL, so the current title is obtained again.
*/
VIM_CLEAR(oldtitle);
# endif
settmode(TMODE_RAW);
need_check_timestamps = TRUE;
did_check_timestamps = FALSE;
after_sigcont();
#else
suspend_shell();
#endif
@@ -1410,7 +1452,7 @@ set_signals(void)
#ifdef SIGTSTP
signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
#endif
#if defined(_REENTRANT) && defined(SIGCONT)
#if defined(SIGCONT)
signal(SIGCONT, sigcont_handler);
#endif
@@ -2296,17 +2338,21 @@ mch_settitle(char_u *title, char_u *icon)
/*
* Restore the window/icon title.
* "which" is one of:
* 1 only restore title
* 2 only restore icon
* 3 restore title and icon
* SAVE_RESTORE_TITLE only restore title
* SAVE_RESTORE_ICON only restore icon
* SAVE_RESTORE_BOTH restore title and icon
*/
void
mch_restore_title(int which)
{
/* only restore the title or icon when it has been set */
mch_settitle(((which & 1) && did_set_title) ?
mch_settitle(((which & SAVE_RESTORE_TITLE) && did_set_title) ?
(oldtitle ? oldtitle : p_titleold) : NULL,
((which & 2) && did_set_icon) ? oldicon : NULL);
((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);
// pop and push from/to the stack
term_pop_title(which);
term_push_title(which);
}
#endif /* FEAT_TITLE */
@@ -3376,7 +3422,9 @@ mch_exit(int r)
{
settmode(TMODE_COOK);
#ifdef FEAT_TITLE
mch_restore_title(3); /* restore xterm title and icon name */
// restore xterm title and icon name
mch_restore_title(SAVE_RESTORE_BOTH);
term_pop_title(SAVE_RESTORE_BOTH);
#endif
/*
* When t_ti is not empty but it doesn't cause swapping terminal
+53 -23
View File
@@ -2695,7 +2695,7 @@ mch_exit(int r)
if (g_fWindInitCalled)
{
#ifdef FEAT_TITLE
mch_restore_title(3);
mch_restore_title(SAVE_RESTORE_BOTH);
/*
* Restore both the small and big icons of the console window to
* what they were at startup. Don't do this when the window is
@@ -3966,6 +3966,48 @@ mch_get_shellsize(void)
return OK;
}
/*
* Resize console buffer to 'COORD'
*/
static void
ResizeConBuf(
HANDLE hConsole,
COORD coordScreen)
{
if (!SetConsoleScreenBufferSize(hConsole, coordScreen))
{
#ifdef MCH_WRITE_DUMP
if (fdDump)
{
fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n",
GetLastError());
fflush(fdDump);
}
#endif
}
}
/*
* Resize console window size to 'srWindowRect'
*/
static void
ResizeWindow(
HANDLE hConsole,
SMALL_RECT srWindowRect)
{
if (!SetConsoleWindowInfo(hConsole, TRUE, &srWindowRect))
{
#ifdef MCH_WRITE_DUMP
if (fdDump)
{
fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n",
GetLastError());
fflush(fdDump);
}
#endif
}
}
/*
* Set a console window to `xSize' * `ySize'
*/
@@ -4019,32 +4061,20 @@ ResizeConBufAndWindow(
}
}
if (!SetConsoleWindowInfo(g_hConOut, TRUE, &srWindowRect))
{
#ifdef MCH_WRITE_DUMP
if (fdDump)
{
fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n",
GetLastError());
fflush(fdDump);
}
#endif
}
/* define the new console buffer size */
// define the new console buffer size
coordScreen.X = xSize;
coordScreen.Y = ySize;
if (!SetConsoleScreenBufferSize(hConsole, coordScreen))
// In the new console call API in reverse order
if (!vtp_working)
{
#ifdef MCH_WRITE_DUMP
if (fdDump)
{
fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n",
GetLastError());
fflush(fdDump);
}
#endif
ResizeWindow(hConsole, srWindowRect);
ResizeConBuf(hConsole, coordScreen);
}
else
{
ResizeConBuf(hConsole, coordScreen);
ResizeWindow(hConsole, srWindowRect);
}
}
+1
View File
@@ -34,4 +34,5 @@ char_u *ml_encrypt_data(memfile_T *mfp, char_u *data, off_T offset, unsigned siz
void ml_decrypt_data(memfile_T *mfp, char_u *data, off_T offset, unsigned size);
long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp);
void goto_byte(long cnt);
char_u *make_percent_swname (char_u *dir, char_u *name);
/* vim: set ft=c : */
+3
View File
@@ -31,6 +31,8 @@ void term_bg_color(int n);
void term_fg_rgb_color(guicolor_T rgb);
void term_bg_rgb_color(guicolor_T rgb);
void term_settitle(char_u *title);
void term_push_title(int which);
void term_pop_title(int which);
void ttest(int pairs);
void add_long_to_buf(long_u val, char_u *dst);
void check_shellsize(void);
@@ -50,6 +52,7 @@ void setmouse(void);
int mouse_has(int c);
int mouse_model_popup(void);
void scroll_start(void);
void cursor_on_force(void);
void cursor_on(void);
void cursor_off(void);
void term_cursor_mode(int forced);
+544 -328
View File
File diff suppressed because it is too large Load Diff
+56 -4
View File
@@ -922,6 +922,10 @@ static struct builtin_term builtin_termcaps[] =
# endif
{(int)KS_CBE, IF_EB("\033[?2004h", ESC_STR "[?2004h")},
{(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")},
{(int)KS_CST, IF_EB("\033[22;2t", ESC_STR "[22;2t")},
{(int)KS_CRT, IF_EB("\033[23;2t", ESC_STR "[23;2t")},
{(int)KS_SSI, IF_EB("\033[22;1t", ESC_STR "[22;1t")},
{(int)KS_SRI, IF_EB("\033[23;1t", ESC_STR "[23;1t")},
{K_UP, IF_EB("\033O*A", ESC_STR "O*A")},
{K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")},
@@ -1606,6 +1610,8 @@ get_term_entries(int *height, int *width)
{KS_8F, "8f"}, {KS_8B, "8b"},
{KS_CBE, "BE"}, {KS_CBD, "BD"},
{KS_CPS, "PS"}, {KS_CPE, "PE"},
{KS_CST, "ST"}, {KS_CRT, "RT"},
{KS_SSI, "Si"}, {KS_SRI, "Ri"},
{(enum SpecialKey)0, NULL}
};
int i;
@@ -2980,6 +2986,45 @@ term_settitle(char_u *title)
out_str(T_FS); /* set title end */
out_flush();
}
/*
* Tell the terminal to push (save) the title and/or icon, so that it can be
* popped (restored) later.
*/
void
term_push_title(int which)
{
if ((which & SAVE_RESTORE_TITLE) && *T_CST != NUL)
{
OUT_STR(T_CST);
out_flush();
}
if ((which & SAVE_RESTORE_ICON) && *T_SSI != NUL)
{
OUT_STR(T_SSI);
out_flush();
}
}
/*
* Tell the terminal to pop the title and/or icon.
*/
void
term_pop_title(int which)
{
if ((which & SAVE_RESTORE_TITLE) && *T_CRT != NUL)
{
OUT_STR(T_CRT);
out_flush();
}
if ((which & SAVE_RESTORE_ICON) && *T_SRI != NUL)
{
OUT_STR(T_SRI);
out_flush();
}
}
#endif
/*
@@ -3794,6 +3839,16 @@ scroll_start(void)
static int cursor_is_off = FALSE;
/*
* Enable the cursor without checking if it's already enabled.
*/
void
cursor_on_force(void)
{
out_str(T_VE);
cursor_is_off = FALSE;
}
/*
* Enable the cursor.
*/
@@ -3801,10 +3856,7 @@ static int cursor_is_off = FALSE;
cursor_on(void)
{
if (cursor_is_off)
{
out_str(T_VE);
cursor_is_off = FALSE;
}
cursor_on_force();
}
/*
+10 -2
View File
@@ -101,10 +101,14 @@ enum SpecialKey
KS_CBE, /* enable bracketed paste mode */
KS_CBD, /* disable bracketed paste mode */
KS_CPS, /* start of bracketed paste */
KS_CPE /* end of bracketed paste */
KS_CPE, /* end of bracketed paste */
KS_CST, /* save window title */
KS_CRT, /* restore window title */
KS_SSI, /* save icon text */
KS_SRI /* restore icon text */
};
#define KS_LAST KS_CPE
#define KS_LAST KS_SRI
/*
* the terminal capabilities are stored in this array
@@ -196,6 +200,10 @@ extern char_u *(term_strings[]); /* current terminal strings */
#define T_BD (TERM_STR(KS_CBD)) /* disable bracketed paste mode */
#define T_PS (TERM_STR(KS_CPS)) /* start of bracketed paste */
#define T_PE (TERM_STR(KS_CPE)) /* end of bracketed paste */
#define T_CST (TERM_STR(KS_CST)) /* save window title */
#define T_CRT (TERM_STR(KS_CRT)) /* restore window title */
#define T_SSI (TERM_STR(KS_SSI)) /* save icon text */
#define T_SRI (TERM_STR(KS_SRI)) /* restore icon text */
#define TMODE_COOK 0 /* terminal mode for external cmds and Ex mode */
#define TMODE_SLEEP 1 /* terminal mode for sleeping (cooked but no echo) */
+7 -1
View File
@@ -2823,11 +2823,17 @@ term_after_channel_closed(term_T *term)
if (term->tl_finish == TL_FINISH_CLOSE)
{
aco_save_T aco;
int do_set_w_closing = term->tl_buffer->b_nwindows == 0;
/* ++close or term_finish == "close" */
// ++close or term_finish == "close"
ch_log(NULL, "terminal job finished, closing window");
aucmd_prepbuf(&aco, term->tl_buffer);
// Avoid closing the window if we temporarily use it.
if (do_set_w_closing)
curwin->w_closing = TRUE;
do_bufdel(DOBUF_WIPE, (char_u *)"", 1, fnum, fnum, FALSE);
if (do_set_w_closing)
curwin->w_closing = FALSE;
aucmd_restbuf(&aco);
return TRUE;
}
+1 -1
View File
@@ -701,7 +701,7 @@ vim.foreach_rtp(FailingCall()):NotImplementedError:('call',)
vim.foreach_rtp(int, 2):TypeError:('foreach_rtp() takes exactly one argument (2 given)',)
> import
import xxx_no_such_module_xxx:ImportError:('No module named xxx_no_such_module_xxx',)
import failing_import:ImportError:('No module named failing_import',)
import failing_import:ImportError:()
import failing:NotImplementedError:()
> Options
>> OptionsItem
+1
View File
@@ -2,6 +2,7 @@
" This makes testing go faster, since Vim doesn't need to restart.
source test_assign.vim
source test_backup.vim
source test_bufline.vim
source test_cd.vim
source test_changedtick.vim
+24 -1
View File
@@ -587,7 +587,7 @@ func Test_OptionSet()
" Cleanup
au! OptionSet
for opt in ['nu', 'ai', 'acd', 'ar', 'bs', 'backup', 'cul', 'cp']
exe printf(":set %s&vi", opt)
exe printf(":set %s&vim", opt)
endfor
call test_override('starting', 0)
delfunc! AutoCommandOptionSet
@@ -1313,6 +1313,29 @@ func Test_ChangedP()
bw!
endfunc
let g:setline_handled = v:false
func! SetLineOne()
if !g:setline_handled
call setline(1, "(x)")
let g:setline_handled = v:true
endif
endfunc
func Test_TextChangedI_with_setline()
new
call test_override('char_avail', 1)
autocmd TextChangedI <buffer> call SetLineOne()
call feedkeys("i(\<CR>\<Esc>", 'tx')
call assert_equal('(', getline(1))
call assert_equal('x)', getline(2))
undo
call assert_equal('', getline(1))
call assert_equal('', getline(2))
call test_override('starting', 0)
bwipe!
endfunc
func Test_Changed_FirstTime()
if !has('terminal') || has('gui_running')
return
+58
View File
@@ -0,0 +1,58 @@
" Tests for the backup function
func Test_backup()
set backup backupdir=. backupskip=
new
call setline(1, ['line1', 'line2'])
:f Xbackup.txt
:w! Xbackup.txt
" backup file is only created after
" writing a second time (before overwriting)
:w! Xbackup.txt
let l = readfile('Xbackup.txt~')
call assert_equal(['line1', 'line2'], l)
bw!
set backup&vim backupdir&vim backupskip&vim
call delete('Xbackup.txt')
call delete('Xbackup.txt~')
endfunc
func Test_backup2()
set backup backupdir=.// backupskip=
new
call setline(1, ['line1', 'line2', 'line3'])
:f Xbackup.txt
:w! Xbackup.txt
" backup file is only created after
" writing a second time (before overwriting)
:w! Xbackup.txt
sp *Xbackup.txt~
call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
let f=expand('%')
call assert_match('%testdir%Xbackup.txt\~', f)
bw!
bw!
call delete('Xbackup.txt')
call delete(f)
set backup&vim backupdir&vim backupskip&vim
endfunc
func Test_backup2_backupcopy()
set backup backupdir=.// backupcopy=yes backupskip=
new
call setline(1, ['line1', 'line2', 'line3'])
:f Xbackup.txt
:w! Xbackup.txt
" backup file is only created after
" writing a second time (before overwriting)
:w! Xbackup.txt
sp *Xbackup.txt~
call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
let f=expand('%')
call assert_match('%testdir%Xbackup.txt\~', f)
bw!
bw!
call delete('Xbackup.txt')
call delete(f)
set backup&vim backupdir&vim backupcopy&vim backupskip&vim
endfunc
+15
View File
@@ -208,6 +208,21 @@ func Test_simplify()
call assert_fails('call simplify(1.2)', 'E806:')
endfunc
func Test_pathshorten()
call assert_equal('', pathshorten(''))
call assert_equal('foo', pathshorten('foo'))
call assert_equal('/foo', pathshorten('/foo'))
call assert_equal('f/', pathshorten('foo/'))
call assert_equal('f/bar', pathshorten('foo/bar'))
call assert_equal('f/b/foobar', pathshorten('foo/bar/foobar'))
call assert_equal('/f/b/foobar', pathshorten('/foo/bar/foobar'))
call assert_equal('.f/bar', pathshorten('.foo/bar'))
call assert_equal('~f/bar', pathshorten('~foo/bar'))
call assert_equal('~.f/bar', pathshorten('~.foo/bar'))
call assert_equal('.~f/bar', pathshorten('.~foo/bar'))
call assert_equal('~/f/bar', pathshorten('~/foo/bar'))
endfunc
func Test_strpart()
call assert_equal('de', strpart('abcdefg', 3, 2))
call assert_equal('ab', strpart('abcdefg', -2, 4))
+13
View File
@@ -262,6 +262,19 @@ function Test_CompleteDoneList()
au! CompleteDone
endfunc
func Test_CompleteDone_undo()
au CompleteDone * call append(0, "prepend1")
new
call setline(1, ["line1", "line2"])
call feedkeys("Go\<C-X>\<C-N>\<CR>\<ESC>", "tx")
call assert_equal(["prepend1", "line1", "line2", "line1", ""],
\ getline(1, '$'))
undo
call assert_equal(["line1", "line2"], getline(1, '$'))
bwipe!
au! CompleteDone
endfunc
" Check that when using feedkeys() typeahead does not interrupt searching for
" completions.
func Test_compl_feedkeys()
+24
View File
@@ -3478,6 +3478,30 @@ func Xautocmd_changelist(cchar)
call assert_equal(5, line('.'))
autocmd! QuickFixCmdPost
" Test for autocommands clearing the quickfix list before jumping to the
" first error. This should not result in an error
autocmd QuickFixCmdPost * call g:Xsetlist([], 'r')
let v:errmsg = ''
" Test for cfile/lfile
Xfile Xerr
call assert_true(v:errmsg !~# 'E42:')
" Test for cbuffer/lbuffer
edit Xerr
Xbuffer
call assert_true(v:errmsg !~# 'E42:')
" Test for cexpr/lexpr
Xexpr 'Xtestfile2:4:Line4'
call assert_true(v:errmsg !~# 'E42:')
" Test for grep/lgrep
" The grepprg may not be set on non-Unix systems
if has('unix')
silent Xgrep Line5 Xtestfile2
call assert_true(v:errmsg !~# 'E42:')
endif
" Test for vimgrep/lvimgrep
call assert_fails('silent Xvimgrep Line5 Xtestfile2', 'E480:')
autocmd! QuickFixCmdPost
call delete('Xerr')
call delete('Xtestfile1')
call delete('Xtestfile2')
+35
View File
@@ -122,6 +122,41 @@ func Test_nonexistent_file()
call assert_equal('', getfperm(fname))
endfunc
func Test_getftype()
call assert_equal('file', getftype(v:progpath))
call assert_equal('dir', getftype('.'))
if !has('unix')
return
endif
silent !ln -s Xfile Xlink
call assert_equal('link', getftype('Xlink'))
call delete('Xlink')
if executable('mkfifo')
silent !mkfifo Xfifo
call assert_equal('fifo', getftype('Xfifo'))
call delete('Xfifo')
endif
for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null')
call assert_equal('cdev', getftype(cdevfile))
endfor
for bdevfile in systemlist('find /dev -type b -maxdepth 2 2>/dev/null')
call assert_equal('bdev', getftype(bdevfile))
endfor
" The /run/ directory typically contains socket files.
" If it does not, test won't fail but will not test socket files.
for socketfile in systemlist('find /run -type s -maxdepth 2 2>/dev/null')
call assert_equal('socket', getftype(socketfile))
endfor
" TODO: file type 'other' is not tested. How can we test it?
endfunc
func Test_win32_symlink_dir()
" On Windows, non-admin users cannot create symlinks.
" So we use an existing symlink for this test.
+13
View File
@@ -105,6 +105,19 @@ function Test_tabpage()
call assert_equal(4, tabpagenr())
7tabmove 5
call assert_equal(5, tabpagenr())
" The following are a no-op
norm! 2gt
call assert_equal(2, tabpagenr())
tabmove 2
call assert_equal(2, tabpagenr())
2tabmove
call assert_equal(2, tabpagenr())
tabmove 1
call assert_equal(2, tabpagenr())
1tabmove
call assert_equal(2, tabpagenr())
call assert_fails("99tabmove", 'E16:')
call assert_fails("+99tabmove", 'E16:')
call assert_fails("-99tabmove", 'E16:')
+12
View File
@@ -1631,3 +1631,15 @@ func Test_terminal_hidden()
call WaitForAssert({-> assert_equal('finished', term_getstatus(bnr))})
bwipe!
endfunc
func Test_terminal_hidden_and_close()
if !has('unix')
return
endif
call assert_equal(1, winnr('$'))
term ++hidden ++close ls
let bnr = bufnr('$')
call assert_equal('terminal', getbufvar(bnr, '&buftype'))
call WaitForAssert({-> assert_false(bufexists(bnr))})
call assert_equal(1, winnr('$'))
endfunc
+48
View File
@@ -809,6 +809,54 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
264,
/**/
263,
/**/
262,
/**/
261,
/**/
260,
/**/
259,
/**/
258,
/**/
257,
/**/
256,
/**/
255,
/**/
254,
/**/
253,
/**/
252,
/**/
251,
/**/
250,
/**/
249,
/**/
248,
/**/
247,
/**/
246,
/**/
245,
/**/
244,
/**/
243,
/**/
242,
/**/
241,
/**/
240,
/**/
+5
View File
@@ -2550,4 +2550,9 @@ typedef enum {
#define TERM_START_FORCEIT 2
#define TERM_START_SYSTEM 4
// Used for icon/title save and restore.
#define SAVE_RESTORE_TITLE 1
#define SAVE_RESTORE_ICON 2
#define SAVE_RESTORE_BOTH (SAVE_RESTORE_TITLE | SAVE_RESTORE_ICON)
#endif /* VIM__H */