mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
vim-patch:8.1.0061: fix resetting, setting 'title' #11733
Problem: Window title is wrong after resetting and setting 'title'.
Solution: Move resetting the title into maketitle(). (Jason Franklin)
84a9308511
This commit is contained in:

committed by
Justin M. Keyes

parent
97dcc48c99
commit
e53e860759
@@ -3068,18 +3068,15 @@ void col_print(char_u *buf, size_t buflen, int col, int vcol)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* put file name in title bar of window and in icon title
|
|
||||||
*/
|
|
||||||
|
|
||||||
static char_u *lasttitle = NULL;
|
static char_u *lasttitle = NULL;
|
||||||
static char_u *lasticon = NULL;
|
static char_u *lasticon = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
// Put the title name in the title bar and icon of the window.
|
||||||
void maketitle(void)
|
void maketitle(void)
|
||||||
{
|
{
|
||||||
char_u *t_str = NULL;
|
char_u *title_str = NULL;
|
||||||
char_u *i_name;
|
char_u *icon_str = NULL;
|
||||||
char_u *i_str = NULL;
|
|
||||||
int maxlen = 0;
|
int maxlen = 0;
|
||||||
int len;
|
int len;
|
||||||
int mustset;
|
int mustset;
|
||||||
@@ -3093,7 +3090,7 @@ void maketitle(void)
|
|||||||
|
|
||||||
need_maketitle = false;
|
need_maketitle = false;
|
||||||
if (!p_title && !p_icon && lasttitle == NULL && lasticon == NULL) {
|
if (!p_title && !p_icon && lasttitle == NULL && lasticon == NULL) {
|
||||||
return;
|
return; // nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_title) {
|
if (p_title) {
|
||||||
@@ -3114,14 +3111,14 @@ void maketitle(void)
|
|||||||
build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
|
build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
|
||||||
p_titlestring, use_sandbox,
|
p_titlestring, use_sandbox,
|
||||||
0, maxlen, NULL, NULL);
|
0, maxlen, NULL, NULL);
|
||||||
t_str = (char_u *)buf;
|
title_str = (char_u *)buf;
|
||||||
if (called_emsg) {
|
if (called_emsg) {
|
||||||
set_string_option_direct((char_u *)"titlestring", -1, (char_u *)"",
|
set_string_option_direct((char_u *)"titlestring", -1, (char_u *)"",
|
||||||
OPT_FREE, SID_ERROR);
|
OPT_FREE, SID_ERROR);
|
||||||
}
|
}
|
||||||
called_emsg |= save_called_emsg;
|
called_emsg |= save_called_emsg;
|
||||||
} else {
|
} else {
|
||||||
t_str = p_titlestring;
|
title_str = p_titlestring;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Format: "fname + (path) (1 of 2) - VIM".
|
// Format: "fname + (path) (1 of 2) - VIM".
|
||||||
@@ -3205,16 +3202,16 @@ void maketitle(void)
|
|||||||
trunc_string((char_u *)buf, (char_u *)buf, maxlen, sizeof(buf));
|
trunc_string((char_u *)buf, (char_u *)buf, maxlen, sizeof(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t_str = (char_u *)buf;
|
title_str = (char_u *)buf;
|
||||||
#undef SPACE_FOR_FNAME
|
#undef SPACE_FOR_FNAME
|
||||||
#undef SPACE_FOR_DIR
|
#undef SPACE_FOR_DIR
|
||||||
#undef SPACE_FOR_ARGNR
|
#undef SPACE_FOR_ARGNR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mustset = ti_change(t_str, &lasttitle);
|
mustset = value_change(title_str, &lasttitle);
|
||||||
|
|
||||||
if (p_icon) {
|
if (p_icon) {
|
||||||
i_str = (char_u *)buf;
|
icon_str = (char_u *)buf;
|
||||||
if (*p_iconstring != NUL) {
|
if (*p_iconstring != NUL) {
|
||||||
if (stl_syntax & STL_IN_ICON) {
|
if (stl_syntax & STL_IN_ICON) {
|
||||||
int use_sandbox = false;
|
int use_sandbox = false;
|
||||||
@@ -3222,37 +3219,40 @@ void maketitle(void)
|
|||||||
|
|
||||||
use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
|
use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
|
||||||
called_emsg = false;
|
called_emsg = false;
|
||||||
build_stl_str_hl(curwin, i_str, sizeof(buf),
|
build_stl_str_hl(curwin, icon_str, sizeof(buf),
|
||||||
p_iconstring, use_sandbox,
|
p_iconstring, use_sandbox,
|
||||||
0, 0, NULL, NULL);
|
0, 0, NULL, NULL);
|
||||||
if (called_emsg)
|
if (called_emsg) {
|
||||||
set_string_option_direct((char_u *)"iconstring", -1,
|
set_string_option_direct((char_u *)"iconstring", -1,
|
||||||
(char_u *)"", OPT_FREE, SID_ERROR);
|
(char_u *)"", OPT_FREE, SID_ERROR);
|
||||||
|
}
|
||||||
called_emsg |= save_called_emsg;
|
called_emsg |= save_called_emsg;
|
||||||
} else
|
} else {
|
||||||
i_str = p_iconstring;
|
icon_str = p_iconstring;
|
||||||
} else {
|
|
||||||
if (buf_spname(curbuf) != NULL) {
|
|
||||||
i_name = buf_spname(curbuf);
|
|
||||||
} else { // use file name only in icon
|
|
||||||
i_name = path_tail(curbuf->b_ffname);
|
|
||||||
}
|
}
|
||||||
*i_str = NUL;
|
} else {
|
||||||
|
char_u *buf_p;
|
||||||
|
if (buf_spname(curbuf) != NULL) {
|
||||||
|
buf_p = buf_spname(curbuf);
|
||||||
|
} else { // use file name only in icon
|
||||||
|
buf_p = path_tail(curbuf->b_ffname);
|
||||||
|
}
|
||||||
|
*icon_str = NUL;
|
||||||
// Truncate name at 100 bytes.
|
// Truncate name at 100 bytes.
|
||||||
len = (int)STRLEN(i_name);
|
len = (int)STRLEN(buf_p);
|
||||||
if (len > 100) {
|
if (len > 100) {
|
||||||
len -= 100;
|
len -= 100;
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
len += (*mb_tail_off)(i_name, i_name + len) + 1;
|
len += (*mb_tail_off)(buf_p, buf_p + len) + 1;
|
||||||
}
|
}
|
||||||
i_name += len;
|
buf_p += len;
|
||||||
}
|
}
|
||||||
STRCPY(i_str, i_name);
|
STRCPY(icon_str, buf_p);
|
||||||
trans_characters(i_str, IOSIZE);
|
trans_characters(icon_str, IOSIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mustset |= ti_change(i_str, &lasticon);
|
mustset |= value_change(icon_str, &lasticon);
|
||||||
|
|
||||||
if (mustset) {
|
if (mustset) {
|
||||||
resettitle();
|
resettitle();
|
||||||
@@ -3266,8 +3266,8 @@ void maketitle(void)
|
|||||||
/// @param str desired title string
|
/// @param str desired title string
|
||||||
/// @param[in,out] last current title string
|
/// @param[in,out] last current title string
|
||||||
//
|
//
|
||||||
/// @return true when "*last" changed.
|
/// @return true if resettitle() is to be called.
|
||||||
static bool ti_change(char_u *str, char_u **last)
|
static bool value_change(char_u *str, char_u **last)
|
||||||
FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
if ((str == NULL) != (*last == NULL)
|
if ((str == NULL) != (*last == NULL)
|
||||||
@@ -3275,10 +3275,11 @@ static bool ti_change(char_u *str, char_u **last)
|
|||||||
xfree(*last);
|
xfree(*last);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
*last = NULL;
|
*last = NULL;
|
||||||
|
resettitle();
|
||||||
} else {
|
} else {
|
||||||
*last = vim_strsave(str);
|
*last = vim_strsave(str);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -2021,13 +2021,10 @@ static char_u *check_cedit(void)
|
|||||||
// maketitle() to create and display it.
|
// maketitle() to create and display it.
|
||||||
// When switching the title or icon off, call ui_set_{icon,title}(NULL) to get
|
// When switching the title or icon off, call ui_set_{icon,title}(NULL) to get
|
||||||
// the old value back.
|
// the old value back.
|
||||||
static void did_set_title(
|
static void did_set_title(void)
|
||||||
int icon // Did set icon instead of title
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (starting != NO_SCREEN) {
|
if (starting != NO_SCREEN) {
|
||||||
maketitle();
|
maketitle();
|
||||||
resettitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2986,7 +2983,7 @@ ambw_end:
|
|||||||
} else {
|
} else {
|
||||||
stl_syntax &= ~flagval;
|
stl_syntax &= ~flagval;
|
||||||
}
|
}
|
||||||
did_set_title(varp == &p_iconstring);
|
did_set_title();
|
||||||
|
|
||||||
} else if (varp == &p_sel) { // 'selection'
|
} else if (varp == &p_sel) { // 'selection'
|
||||||
if (*p_sel == NUL
|
if (*p_sel == NUL
|
||||||
@@ -4025,9 +4022,9 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
|
|||||||
(void)buf_init_chartab(curbuf, false); // ignore errors
|
(void)buf_init_chartab(curbuf, false); // ignore errors
|
||||||
} else if ((int *)varp == &p_title) {
|
} else if ((int *)varp == &p_title) {
|
||||||
// when 'title' changed, may need to change the title; same for 'icon'
|
// when 'title' changed, may need to change the title; same for 'icon'
|
||||||
did_set_title(false);
|
did_set_title();
|
||||||
} else if ((int *)varp == &p_icon) {
|
} else if ((int *)varp == &p_icon) {
|
||||||
did_set_title(true);
|
did_set_title();
|
||||||
} else if ((int *)varp == &curbuf->b_changed) {
|
} else if ((int *)varp == &curbuf->b_changed) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
save_file_ff(curbuf); // Buffer is unchanged
|
save_file_ff(curbuf); // Buffer is unchanged
|
||||||
|
Reference in New Issue
Block a user