Merge pull request #38738 from zeertzjq/vim-9.2.0267

vim-patch:9.2.0267,af58a9f
This commit is contained in:
zeertzjq
2026-04-04 06:24:07 +08:00
committed by GitHub
5 changed files with 34 additions and 18 deletions

View File

@@ -822,10 +822,10 @@ A jump table for the options with a short description can be found at |Q_op|.
'autowrite' 'aw' boolean (default off)
global
Write the contents of the file, if it has been modified, on each
`:next`, `:rewind`, `:last`, `:first`, `:previous`, `:stop`,
`:suspend`, `:tag`, `:!`, `:make`, CTRL-] and CTRL-^ command; and when
a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one
to another file.
`:next`, `:rewind`, `:last`, `:first`, `:previous`, `:tag`, `:stop`,
`:suspend`, `:!`, `:make`, `:terminal`, CTRL-] or CTRL-^ command; and
when a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command
switches to another file.
A buffer is not written if it becomes hidden, e.g. when 'bufhidden' is
set to "hide" and `:next` is used.
Note that for some commands the 'autowrite' option is not used, see
@@ -839,8 +839,8 @@ A jump table for the options with a short description can be found at |Q_op|.
*'autowriteall'* *'awa'* *'noautowriteall'* *'noawa'*
'autowriteall' 'awa' boolean (default off)
global
Like 'autowrite', but also used for commands ":edit", ":enew",
":quit", ":qall", ":exit", ":xit", ":recover" and closing the Vim
Like 'autowrite', but also used for commands `:edit`, `:enew`,
`:quit`, `:qall`, `:exit`, `:xit`, `:recover` and closing the Vim
window.
Setting this option also implies that Vim behaves like 'autowrite' has
been set.

View File

@@ -189,10 +189,10 @@ vim.go.autoread = vim.o.autoread
vim.go.ar = vim.go.autoread
--- Write the contents of the file, if it has been modified, on each
--- `:next`, `:rewind`, `:last`, `:first`, `:previous`, `:stop`,
--- `:suspend`, `:tag`, `:!`, `:make`, CTRL-] and CTRL-^ command; and when
--- a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one
--- to another file.
--- `:next`, `:rewind`, `:last`, `:first`, `:previous`, `:tag`, `:stop`,
--- `:suspend`, `:!`, `:make`, `:terminal`, CTRL-] or CTRL-^ command; and
--- when a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command
--- switches to another file.
--- A buffer is not written if it becomes hidden, e.g. when 'bufhidden' is
--- set to "hide" and `:next` is used.
--- Note that for some commands the 'autowrite' option is not used, see
@@ -209,8 +209,8 @@ vim.o.aw = vim.o.autowrite
vim.go.autowrite = vim.o.autowrite
vim.go.aw = vim.go.autowrite
--- Like 'autowrite', but also used for commands ":edit", ":enew",
--- ":quit", ":qall", ":exit", ":xit", ":recover" and closing the Vim
--- Like 'autowrite', but also used for commands `:edit`, `:enew`,
--- `:quit`, `:qall`, `:exit`, `:xit`, `:recover` and closing the Vim
--- window.
--- Setting this option also implies that Vim behaves like 'autowrite' has
--- been set.

View File

@@ -8197,6 +8197,11 @@ static void ex_terminal(exarg_T *eap)
{
char ex_cmd[1024];
size_t len = 0;
const int scroll_save = msg_scroll;
msg_scroll = false; // don't scroll here
autowrite_all();
msg_scroll = scroll_save;
if (cmdmod.cmod_tab > 0 || cmdmod.cmod_split != 0) {
bool multi_mods = false;

View File

@@ -323,10 +323,10 @@ local options = {
defaults = false,
desc = [=[
Write the contents of the file, if it has been modified, on each
`:next`, `:rewind`, `:last`, `:first`, `:previous`, `:stop`,
`:suspend`, `:tag`, `:!`, `:make`, CTRL-] and CTRL-^ command; and when
a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one
to another file.
`:next`, `:rewind`, `:last`, `:first`, `:previous`, `:tag`, `:stop`,
`:suspend`, `:!`, `:make`, `:terminal`, CTRL-] or CTRL-^ command; and
when a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command
switches to another file.
A buffer is not written if it becomes hidden, e.g. when 'bufhidden' is
set to "hide" and `:next` is used.
Note that for some commands the 'autowrite' option is not used, see
@@ -347,8 +347,8 @@ local options = {
abbreviation = 'awa',
defaults = false,
desc = [=[
Like 'autowrite', but also used for commands ":edit", ":enew",
":quit", ":qall", ":exit", ":xit", ":recover" and closing the Vim
Like 'autowrite', but also used for commands `:edit`, `:enew`,
`:quit`, `:qall`, `:exit`, `:xit`, `:recover` and closing the Vim
window.
Setting this option also implies that Vim behaves like 'autowrite' has
been set.

View File

@@ -106,6 +106,17 @@ describe(':terminal', function()
eq(3, #jumps)
end)
it("triggers 'autowrite'", function()
api.nvim_set_option_value('autowrite', true, {})
command('vnew Xtermautowritetestfile | setlocal fileformat=unix')
finally(function()
os.remove('Xtermautowritetestfile')
end)
fn.setline(1, 'test content')
command('terminal')
eq('test content\n', t.read_file('Xtermautowritetestfile'))
end)
it('nvim_get_mode() in :terminal', function()
command('terminal')
eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())