aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/usr_41.txt1
-rw-r--r--src/nvim/ascii.h2
-rw-r--r--src/nvim/autocmd.c12
-rw-r--r--src/nvim/edit.c8
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/screen.c4
-rw-r--r--src/nvim/testdir/test_compiler.vim4
-rw-r--r--src/nvim/tui/tui.c22
-rw-r--r--test/functional/lua/buffer_updates_spec.lua26
-rw-r--r--test/functional/ui/cmdline_spec.lua12
10 files changed, 78 insertions, 18 deletions
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index a606fabe7a..21f5dcc815 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -960,6 +960,7 @@ Testing: *test-functions*
assert_true() assert that an expression is true
assert_exception() assert that a command throws an exception
assert_beeps() assert that a command beeps
+ assert_nobeep() assert that a command does not cause a beep
assert_fails() assert that a command fails
Timers: *timer-functions*
diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h
index f41068ea70..7e4dee3d34 100644
--- a/src/nvim/ascii.h
+++ b/src/nvim/ascii.h
@@ -31,7 +31,9 @@
#define CSI 0x9b // Control Sequence Introducer
#define CSI_STR "\233"
#define DCS 0x90 // Device Control String
+#define DCS_STR "\033P"
#define STERM 0x9c // String Terminator
+#define STERM_STR "\033\\"
#define POUND 0xA3
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index f71075ae74..145f6f5601 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -1621,13 +1621,21 @@ static bool apply_autocmds_group(event_T event,
ap->last = false;
}
ap->last = true;
- check_lnums(true); // make sure cursor and topline are valid
+
+ if (nesting == 1) {
+ // make sure cursor and topline are valid
+ check_lnums(true);
+ }
// Execute the autocmd. The `getnextac` callback handles iteration.
do_cmdline(NULL, getnextac, (void *)&patcmd,
DOCMD_NOWAIT | DOCMD_VERBOSE | DOCMD_REPEAT);
- reset_lnums(); // restore cursor and topline, unless they were changed
+ if (nesting == 1) {
+ // restore cursor and topline, unless they were changed
+ reset_lnums();
+ }
+
if (eap != NULL) {
(void)set_cmdarg(NULL, save_cmdarg);
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 49bd170bcd..be0ab33d08 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -8787,10 +8787,6 @@ static bool ins_tab(void)
getvcol(curwin, &fpos, &vcol, NULL, NULL);
getvcol(curwin, cursor, &want_vcol, NULL, NULL);
- // save start of changed region for extmark_splice
- int start_row = fpos.lnum;
- colnr_T start_col = fpos.col;
-
// Use as many TABs as possible. Beware of 'breakindent', 'showbreak'
// and 'linebreak' adding extra virtual columns.
while (ascii_iswhite(*ptr)) {
@@ -8841,8 +8837,8 @@ static bool ins_tab(void)
}
}
if (!(State & VREPLACE_FLAG)) {
- extmark_splice_cols(curbuf, start_row - 1, start_col,
- cursor->col - start_col, fpos.col - start_col,
+ extmark_splice_cols(curbuf, fpos.lnum - 1, change_col,
+ cursor->col - change_col, fpos.col - change_col,
kExtmarkUndo);
}
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index d34282419a..b191e8cf67 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -790,7 +790,8 @@ void ex_retab(exarg_T *eap)
/* len is actual number of white characters used */
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
- new_line = xmalloc(old_len - col + start_col + len + 1);
+ long new_len = old_len - col + start_col + len + 1;
+ new_line = xmalloc(new_len);
if (start_col > 0)
memmove(new_line, ptr, (size_t)start_col);
@@ -803,6 +804,8 @@ void ex_retab(exarg_T *eap)
if (ml_replace(lnum, new_line, false) == OK) {
// "new_line" may have been copied
new_line = curbuf->b_ml.ml_line_ptr;
+ extmark_splice_cols(curbuf, lnum - 1, 0, (colnr_T)old_len,
+ (colnr_T)new_len - 1, kExtmarkUndo);
}
if (first_line == 0) {
first_line = lnum;
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 404f402830..db033ee1ed 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -7509,6 +7509,10 @@ void screen_resize(int width, int height)
Rows = height;
Columns = width;
check_shellsize();
+ int max_p_ch = Rows - min_rows() + 1;
+ if (!ui_has(kUIMessages) && p_ch > max_p_ch) {
+ p_ch = max_p_ch ? max_p_ch : 1;
+ }
height = Rows;
width = Columns;
p_lines = Rows;
diff --git a/src/nvim/testdir/test_compiler.vim b/src/nvim/testdir/test_compiler.vim
index d361205baa..c3de7d0050 100644
--- a/src/nvim/testdir/test_compiler.vim
+++ b/src/nvim/testdir/test_compiler.vim
@@ -60,10 +60,10 @@ func Test_compiler_completion()
call assert_match('^"compiler ' .. clist .. '$', @:)
call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_equal('"compiler pbx perl php pylint pyunit', @:)
+ call assert_match('"compiler pbx perl\( p[a-z]\+\)\+ pylint pyunit', @:)
call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_equal('"compiler! pbx perl php pylint pyunit', @:)
+ call assert_match('"compiler! pbx perl\( p[a-z]\+\)\+ pylint pyunit', @:)
endfunc
func Test_compiler_error()
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 62d7dc8b18..ed40a64c66 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -55,7 +55,11 @@
#define STARTS_WITH(str, prefix) (strlen(str) >= (sizeof(prefix) - 1) \
&& 0 == memcmp((str), (prefix), sizeof(prefix) - 1))
#define TMUX_WRAP(is_tmux, seq) ((is_tmux) \
- ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq)
+ ? DCS_STR "tmux;\x1b" seq STERM_STR : seq)
+#define SCREEN_TMUX_WRAP(is_screen, is_tmux, seq) \
+ ((is_screen) \
+ ? DCS_STR seq STERM_STR : (is_tmux) \
+ ? DCS_STR "tmux;\x1b" seq STERM_STR : seq)
#define LINUXSET0C "\x1b[?0c"
#define LINUXSET1C "\x1b[?1c"
@@ -297,6 +301,12 @@ static void terminfo_start(UI *ui)
data->invis, sizeof data->invis);
// Set 't_Co' from the result of unibilium & fix_terminfo.
t_colors = unibi_get_num(data->ut, unibi_max_colors);
+ // Ask the terminal to send us the background color.
+ // If get_bg is sent at the same time after enter_ca_mode, tmux will not send
+ // get_bg to the host terminal. To avoid this, send get_bg before
+ // enter_ca_mode.
+ data->input.waiting_for_bg_response = 5;
+ unibi_out_ext(ui, data->unibi_ext.get_bg);
// Enter alternate screen, save title, and clear.
// NOTE: Do this *before* changing terminal settings. #6433
unibi_out(ui, unibi_enter_ca_mode);
@@ -304,9 +314,6 @@ static void terminfo_start(UI *ui)
unibi_out_ext(ui, data->unibi_ext.save_title);
unibi_out(ui, unibi_keypad_xmit);
unibi_out(ui, unibi_clear_screen);
- // Ask the terminal to send us the background color.
- data->input.waiting_for_bg_response = 5;
- unibi_out_ext(ui, data->unibi_ext.get_bg);
// Enable bracketed paste
unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste);
@@ -328,6 +335,7 @@ static void terminfo_start(UI *ui)
uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0);
uv_pipe_open(&data->output_handle.pipe, data->out_fd);
}
+
flush_buf(ui);
}
@@ -1772,8 +1780,10 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
#define XTERM_SETAB_16 \
"\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m"
- data->unibi_ext.get_bg = (int)unibi_add_ext_str(ut, "ext.get_bg",
- "\x1b]11;?\x07");
+ data->unibi_ext.get_bg =
+ (int)unibi_add_ext_str(ut, "ext.get_bg",
+ SCREEN_TMUX_WRAP((screen && !tmux), tmux,
+ "\x1b]11;?\x07"));
// Terminals with 256-colour SGR support despite what terminfo says.
if (unibi_get_num(ut, unibi_max_colors) < 256) {
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 6d7d9b4d8b..abca018059 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -670,7 +670,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
command("set noet")
command("set ts=4")
command("set sw=2")
- command("set sts=2")
+ command("set sts=4")
local check_events = setup_eventcheck(verify, {'asdfasdf'})
@@ -689,6 +689,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
{ "test1", "bytes", 1, 7, 0, 0, 0, 0, 4, 4, 0, 1, 1 },
}
+
feed("<esc>u")
check_events {
{ "test1", "bytes", 1, 8, 0, 0, 0, 0, 1, 1, 0, 4, 4 },
@@ -728,6 +729,29 @@ describe('lua: nvim_buf_attach on_bytes', function()
{ "test1", "bytes", 1, 29, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
{ "test1", "bytes", 1, 31, 0, 0, 0, 0, 4, 4, 0, 1, 1 };
}
+
+ -- inserting tab after other tabs
+ command("set sw=4")
+ feed("<esc>0a<tab>")
+ check_events {
+ { "test1", "bytes", 1, 32, 0, 1, 1, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 33, 0, 2, 2, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 34, 0, 3, 3, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 35, 0, 4, 4, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 36, 0, 1, 1, 0, 4, 4, 0, 1, 1 };
+ }
+ end)
+
+ it("retab", function()
+ command("set noet")
+ command("set ts=4")
+
+ local check_events = setup_eventcheck(verify, {" asdf"})
+ command("retab 8")
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 0, 7, 7, 0, 9, 9 };
+ }
end)
it("sends events when undoing with undofile", function()
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 21c01b3458..29a76c7a07 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
local command = helpers.command
+local assert_alive = helpers.assert_alive
local function new_screen(opt)
local screen = Screen.new(25, 5)
@@ -842,3 +843,14 @@ describe('cmdline redraw', function()
]], unchanged=true}
end)
end)
+
+describe("cmdline height", function()
+ it("does not crash resized screen #14263", function()
+ clear()
+ local screen = Screen.new(25, 10)
+ screen:attach()
+ command('set cmdheight=9999')
+ screen:try_resize(25, 5)
+ assert_alive()
+ end)
+end)