This commit is contained in:
Justin M. Keyes
2022-07-18 03:04:00 +02:00
committed by GitHub
7 changed files with 58 additions and 23 deletions

View File

@@ -2056,6 +2056,12 @@ static void f_exepath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
(void)os_can_exe(tv_get_string(&argvars[0]), &path, true);
#ifdef BACKSLASH_IN_FILENAME
if (path != NULL) {
slash_adjust((char_u *)path);
}
#endif
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)path;
}

View File

@@ -104,6 +104,10 @@ char *get_xdg_home(const XDGVarType idx)
#else
dir = concat_fnames_realloc(dir, "nvim", true);
#endif
#ifdef BACKSLASH_IN_FILENAME
slash_adjust((char_u *)dir);
#endif
}
return dir;
}

View File

@@ -137,8 +137,7 @@ struct TUIData {
char *space_buf;
};
static bool volatile got_winch = false;
static bool did_user_set_dimensions = false;
static int got_winch = 0;
static bool cursor_style_enabled = false;
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -536,7 +535,7 @@ static void sigcont_cb(SignalWatcher *watcher, int signum, void *data)
static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
{
got_winch = true;
got_winch++;
UI *ui = data;
if (tui_is_stopped(ui)) {
return;
@@ -989,7 +988,7 @@ static void tui_grid_resize(UI *ui, Integer g, Integer width, Integer height)
r->right = MIN(r->right, grid->width);
}
if (!got_winch && (!data->is_starting || did_user_set_dimensions)) {
if (!got_winch && !data->is_starting) {
// Resize the _host_ terminal.
UNIBI_SET_NUM_VAR(data->params[0], (int)height);
UNIBI_SET_NUM_VAR(data->params[1], (int)width);
@@ -999,7 +998,7 @@ static void tui_grid_resize(UI *ui, Integer g, Integer width, Integer height)
reset_scroll_region(ui, ui->width == grid->width);
}
} else { // Already handled the SIGWINCH signal; avoid double-resize.
got_winch = false;
got_winch = got_winch > 0 ? got_winch - 1 : 0;
grid->row = -1;
}
}
@@ -1507,23 +1506,13 @@ static void tui_guess_size(UI *ui)
TUIData *data = ui->data;
int width = 0, height = 0;
// 1 - look for non-default 'columns' and 'lines' options during startup
if (data->is_starting && (Columns != DFLT_COLS || Rows != DFLT_ROWS)) {
did_user_set_dimensions = true;
assert(Columns >= 0);
assert(Rows >= 0);
width = Columns;
height = Rows;
goto end;
}
// 2 - try from a system call(ioctl/TIOCGWINSZ on unix)
// 1 - try from a system call(ioctl/TIOCGWINSZ on unix)
if (data->out_isatty
&& !uv_tty_get_winsize(&data->output_handle.tty, &width, &height)) {
goto end;
}
// 3 - use $LINES/$COLUMNS if available
// 2 - use $LINES/$COLUMNS if available
const char *val;
int advance;
if ((val = os_getenv("LINES"))
@@ -1533,7 +1522,7 @@ static void tui_guess_size(UI *ui)
goto end;
}
// 4 - read from terminfo if available
// 3 - read from terminfo if available
height = unibi_get_num(data->ut, unibi_lines);
width = unibi_get_num(data->ut, unibi_columns);

View File

@@ -23,6 +23,7 @@ local iswin = helpers.iswin
local startswith = helpers.startswith
local write_file = helpers.write_file
local meths = helpers.meths
local alter_slashes = helpers.alter_slashes
describe('startup', function()
before_each(function()
@@ -521,10 +522,12 @@ describe('sysinit', function()
end)
describe('clean', function()
clear()
ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) ~= nil)
clear('--clean')
ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) == nil)
it('--clean', function()
clear()
ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) ~= nil)
clear('--clean')
ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) == nil)
end)
end)
describe('user config init', function()

View File

@@ -86,6 +86,24 @@ describe('TUI', function()
assert_alive()
end)
it('resize at startup', function()
-- Issues: #17285 #15044 #11330
screen:try_resize(50, 10)
feed_command([[call termopen([v:progpath, '--clean', '--cmd', 'let start = reltime() | while v:true | if reltimefloat(reltime(start)) > 2 | break | endif | endwhile']) | sleep 500m | vs new]])
screen:expect([[
{1: } {1:│} |
{4:~ }{1:│}{4:~ }|
{4:~ }{1:│}{4:~ }|
{4:~ }{1:│}{4:~ }|
{4:~ }{1:│}{4:~ }|
{4:~ }{1:│}{5:[No Name] 0,0-1 All}|
{4:~ }{1:│} |
{5:new }{MATCH:<.*[/\]nvim }|
|
{3:-- TERMINAL --} |
]])
end)
it('accepts resize while pager is active', function()
child_session:request("nvim_command", [[
set more

View File

@@ -380,7 +380,7 @@ function Screen:expect(expected, attr_ids, ...)
for i, row in ipairs(expected_rows) do
msg_expected_rows[i] = row
local m = (row ~= actual_rows[i] and row:match('{MATCH:(.*)}') or nil)
if row ~= actual_rows[i] and (not m or not actual_rows[i]:match(m)) then
if row ~= actual_rows[i] and (not m or not (actual_rows[i] and actual_rows[i]:match(m))) then
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
if i <= #actual_rows then
actual_rows[i] = '*' .. actual_rows[i]

View File

@@ -17,6 +17,21 @@ describe('executable()', function()
eq(1, call('executable', 'false'))
end)
if iswin() then
it('exepath respects shellslash', function()
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
eq([[test\functional\fixtures\bin\null.CMD]], call('fnamemodify', call('exepath', 'null'), ':.'))
command('set shellslash')
eq('test/functional/fixtures/bin/null.CMD', call('fnamemodify', call('exepath', 'null'), ':.'))
end)
it('stdpath respects shellslash', function()
eq([[build\Xtest_xdg\share\nvim-data]], call('fnamemodify', call('stdpath', 'data'), ':.'))
command('set shellslash')
eq('build/Xtest_xdg/share/nvim-data', call('fnamemodify', call('stdpath', 'data'), ':.'))
end)
end
it('fails for invalid values', function()
for _, input in ipairs({'v:null', 'v:true', 'v:false', '{}', '[]'}) do
eq('Vim(call):E928: String required', exc_exec('call executable('..input..')'))