Skip to content

Commit 7bc4fe1

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents b305224 + 22f85d0 commit 7bc4fe1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1684
-342
lines changed

runtime/doc/eval.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8231,6 +8231,8 @@ prompt_getprompt({buf}) *prompt_getprompt()*
82318231
Can also be used as a |method|: >
82328232
GetBuffer()->prompt_getprompt()
82338233

8234+
< {only available when compiled with the |+channel| feature}
8235+
82348236

82358237
prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
82368238
Set prompt callback for buffer {buf} to {expr}. When {expr}
@@ -8264,6 +8266,7 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
82648266
< Can also be used as a |method|: >
82658267
GetBuffer()->prompt_setcallback(callback)
82668268

8269+
< {only available when compiled with the |+channel| feature}
82678270

82688271
prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
82698272
Set a callback for buffer {buf} to {expr}. When {expr} is an
@@ -8277,6 +8280,8 @@ prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
82778280
Can also be used as a |method|: >
82788281
GetBuffer()->prompt_setinterrupt(callback)
82798282

8283+
< {only available when compiled with the |+channel| feature}
8284+
82808285
prompt_setprompt({buf}, {text}) *prompt_setprompt()*
82818286
Set prompt for buffer {buf} to {text}. You most likely want
82828287
{text} to end in a space.
@@ -8287,6 +8292,8 @@ prompt_setprompt({buf}, {text}) *prompt_setprompt()*
82878292
Can also be used as a |method|: >
82888293
GetBuffer()->prompt_setprompt('command: ')
82898294

8295+
< {only available when compiled with the |+channel| feature}
8296+
82908297
prop_ functions are documented here: |text-prop-functions|
82918298

82928299
pum_getpos() *pum_getpos()*
@@ -9890,6 +9897,10 @@ sha256({string}) *sha256()*
98909897

98919898
shellescape({string} [, {special}]) *shellescape()*
98929899
Escape {string} for use as a shell command argument.
9900+
When the 'shell' contains powershell (MS-Windows) or pwsh
9901+
(MS-Windows, Linux, and MacOS) then it will enclose {string}
9902+
in single quotes and will double up all internal single
9903+
quotes.
98939904
On MS-Windows, when 'shellslash' is not set, it will enclose
98949905
{string} in double quotes and double all double quotes within
98959906
{string}.
@@ -11052,7 +11063,8 @@ tempname() *tempname()* *temp-file-name*
1105211063
:exe "redir > " . tmpfile
1105311064
< For Unix, the file will be in a private directory |tempfile|.
1105411065
For MS-Windows forward slashes are used when the 'shellslash'
11055-
option is set or when 'shellcmdflag' starts with '-'.
11066+
option is set, or when 'shellcmdflag' starts with '-' and
11067+
'shell' does not contain powershell or pwsh.
1105611068

1105711069

1105811070
term_ functions are documented here: |terminal-function-details|

runtime/doc/options.txt

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6726,23 +6726,25 @@ A jump table for the options with a short description can be found at |Q_op|.
67266726

67276727
*'shellcmdflag'* *'shcf'*
67286728
'shellcmdflag' 'shcf' string (default: "-c";
6729-
Win32, when 'shell' does not contain "sh"
6729+
Win32, when 'shell' contains "powershell":
6730+
"-Command", or when it does not contain "sh"
67306731
somewhere: "/c")
67316732
global
67326733
Flag passed to the shell to execute "!" and ":!" commands; e.g.,
6733-
"bash.exe -c ls" or "cmd.exe /c dir". For MS-Windows, the default is
6734-
set according to the value of 'shell', to reduce the need to set this
6735-
option by the user.
6734+
"bash.exe -c ls", "powershell.exe -Command dir", or "cmd.exe /c dir".
6735+
For MS-Windows, the default is set according to the value of 'shell',
6736+
to reduce the need to set this option by the user.
67366737
On Unix it can have more than one flag. Each white space separated
67376738
part is passed as an argument to the shell command.
67386739
See |option-backslash| about including spaces and backslashes.
6739-
Also see |dos-shell| for MS-Windows.
6740+
Also see |dos-shell| and |dos-powershell| for MS-Windows.
67406741
This option cannot be set from a |modeline| or in the |sandbox|, for
67416742
security reasons.
67426743

67436744
*'shellpipe'* *'sp'*
6744-
'shellpipe' 'sp' string (default ">", ">%s 2>&1", "| tee", "|& tee" or
6745-
"2>&1| tee")
6745+
'shellpipe' 'sp' string (default ">", ">%s 2>&1", "| tee", "|& tee"
6746+
"2>&1| tee", or
6747+
"2>&1 | Out-File -Encoding default")
67466748
global
67476749
{not available when compiled without the |+quickfix|
67486750
feature}
@@ -6752,16 +6754,19 @@ A jump table for the options with a short description can be found at |Q_op|.
67526754
The name of the temporary file can be represented by "%s" if necessary
67536755
(the file name is appended automatically if no %s appears in the value
67546756
of this option).
6755-
For the Amiga the default is ">". For MS-Windows the default is
6756-
">%s 2>&1". The output is directly saved in a file and not echoed to
6757-
the screen.
6757+
For the Amiga the default is ">". For MS-Windows using powershell the
6758+
default is "2>&1 | Out-File -Encoding default", otherwise the default
6759+
is ">%s 2>&1". The output is directly saved in a file and not echoed
6760+
to the screen.
67586761
For Unix the default is "| tee". The stdout of the compiler is saved
67596762
in a file and echoed to the screen. If the 'shell' option is "csh" or
67606763
"tcsh" after initializations, the default becomes "|& tee". If the
67616764
'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
67626765
"bash", "fish", "ash" or "dash" the default becomes "2>&1| tee". This
67636766
means that stderr is also included. Before using the 'shell' option a
67646767
path is removed, thus "/bin/sh" uses "sh".
6768+
For Unix and MS-Windows, when the 'shell' option is "pwsh" the default
6769+
becomes ">%s 2>&1" and the output is not echoed to the screen.
67656770
The initialization of this option is done after reading the ".vimrc"
67666771
and the other initializations, so that when the 'shell' option is set
67676772
there, the 'shellpipe' option changes automatically, unless it was
@@ -6777,23 +6782,21 @@ A jump table for the options with a short description can be found at |Q_op|.
67776782
security reasons.
67786783

67796784
*'shellquote'* *'shq'*
6780-
'shellquote' 'shq' string (default: ""; Win32, when 'shell'
6781-
contains "sh" somewhere: "\"")
6785+
'shellquote' 'shq' string (default: "")
67826786
global
67836787
Quoting character(s), put around the command passed to the shell, for
67846788
the "!" and ":!" commands. The redirection is kept outside of the
67856789
quoting. See 'shellxquote' to include the redirection. It's
67866790
probably not useful to set both options.
67876791
This is an empty string by default. Only known to be useful for
67886792
third-party shells on MS-Windows-like systems, such as the MKS Korn
6789-
Shell or bash, where it should be "\"". The default is adjusted
6790-
according the value of 'shell', to reduce the need to set this option
6791-
by the user. See |dos-shell|.
6793+
Shell or bash, where it should be "\"". See |dos-shell|.
67926794
This option cannot be set from a |modeline| or in the |sandbox|, for
67936795
security reasons.
67946796

67956797
*'shellredir'* *'srr'*
6796-
'shellredir' 'srr' string (default ">", ">&" or ">%s 2>&1")
6798+
'shellredir' 'srr' string (default ">", ">&", ">%s 2>&1", or
6799+
"2>&1 | Out-File -Encoding default")
67976800
global
67986801
String to be used to put the output of a filter command in a temporary
67996802
file. See also |:!|. See |option-backslash| about including spaces
@@ -6804,10 +6807,12 @@ A jump table for the options with a short description can be found at |Q_op|.
68046807
The default is ">". For Unix, if the 'shell' option is "csh" or
68056808
"tcsh" during initializations, the default becomes ">&". If the
68066809
'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
6807-
"bash" or "fish", the default becomes ">%s 2>&1". This means that
6808-
stderr is also included. For Win32, the Unix checks are done and
6809-
additionally "cmd" is checked for, which makes the default ">%s 2>&1".
6810-
Also, the same names with ".exe" appended are checked for.
6810+
"bash", "fish", or "pwsh", the default becomes ">%s 2>&1". This means
6811+
that stderr is also included. For Win32, the Unix checks are done and
6812+
additionally "cmd" is checked for, which makes the default ">%s 2>&1",
6813+
and "powershell" is checked for which makes the default
6814+
"2>&1 | Out-File -Encoding default" (see |dos-powershell|). Also, the
6815+
same names with ".exe" appended are checked for.
68116816
The initialization of this option is done after reading the ".vimrc"
68126817
and the other initializations, so that when the 'shell' option is set
68136818
there, the 'shellredir' option changes automatically unless it was
@@ -6822,9 +6827,9 @@ A jump table for the options with a short description can be found at |Q_op|.
68226827
global
68236828
{only for MS-Windows}
68246829
When set, a forward slash is used when expanding file names. This is
6825-
useful when a Unix-like shell is used instead of cmd.exe. Backward
6826-
slashes can still be typed, but they are changed to forward slashes by
6827-
Vim.
6830+
useful when a Unix-like shell is used instead of cmd.exe, pwsh.exe, or
6831+
powershell.exe. Backward slashes can still be typed, but they are
6832+
changed to forward slashes by Vim.
68286833
Note that setting or resetting this option has no effect for some
68296834
existing file names, thus this option needs to be set before opening
68306835
any file for best results. This might change in the future.
@@ -6878,6 +6883,8 @@ A jump table for the options with a short description can be found at |Q_op|.
68786883
*'shellxquote'* *'sxq'*
68796884
'shellxquote' 'sxq' string (default: "";
68806885
for Win32, when 'shell' is cmd.exe: "("
6886+
for Win32, when 'shell' is
6887+
powershell.exe: "\""
68816888
for Win32, when 'shell' contains "sh"
68826889
somewhere: "\""
68836890
for Unix, when using system(): "\"")
@@ -6890,11 +6897,12 @@ A jump table for the options with a short description can be found at |Q_op|.
68906897
then ')"' is appended.
68916898
When the value is '(' then also see 'shellxescape'.
68926899
This is an empty string by default on most systems, but is known to be
6893-
useful for on Win32 version, either for cmd.exe which automatically
6894-
strips off the first and last quote on a command, or 3rd-party shells
6895-
such as the MKS Korn Shell or bash, where it should be "\"". The
6896-
default is adjusted according the value of 'shell', to reduce the need
6897-
to set this option by the user. See |dos-shell|.
6900+
useful for on Win32 version, either for cmd.exe, powershell.exe, or
6901+
pwsh.exe which automatically strips off the first and last quote on a
6902+
command, or 3rd-party shells such as the MKS Korn Shell or bash, where
6903+
it should be "\"". The default is adjusted according the value of
6904+
'shell', to reduce the need to set this option by the user. See
6905+
|dos-shell|.
68986906
This option cannot be set from a |modeline| or in the |sandbox|, for
68996907
security reasons.
69006908

runtime/doc/os_dos.txt

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ versions of Vim. Also see |os_win32.txt| and |os_msdos.txt|.
1717
7. Interrupting |dos-CTRL-Break|
1818
8. Temp files |dos-temp-files|
1919
9. Shell option default |dos-shell|
20+
10. PowerShell |dos-powershell|
2021

2122
==============================================================================
2223
1. File locations *dos-locations*
@@ -297,8 +298,86 @@ For Win32 as:
297298
<shell> -c "command name >file"
298299
For DOS 32 bit, DJGPP does this internally somehow.
299300

300-
When starting up, Vim checks for the presence of "sh" anywhere in the 'shell'
301-
option. If it is present, Vim sets the 'shellcmdflag' and 'shellquote' or
302-
'shellxquote' options will be set as described above.
301+
When starting up, if Vim does not recognise a standard Windows shell it checks
302+
for the presence of "sh" anywhere in the 'shell' option. If it is present,
303+
Vim sets the 'shellcmdflag' and 'shellquote' or 'shellxquote' options will be
304+
set as described above.
305+
306+
==============================================================================
307+
10. PowerShell *dos-powershell* *dos-pwsh*
308+
309+
Vim supports PowerShell Desktop and PowerShell Core. PowerShell Desktop is
310+
the version of PowerShell that is installed with Windows, while PowerShell
311+
Core is a separate downloadable version that works cross-platform. To see
312+
which version you are using then enter the following in a PowerShell prompt -
313+
$PSVersionTable.PSEdition
314+
315+
If 'shell' includes "powershell" in the filename at startup then VIM sets
316+
'shellcmdflag', 'shellxquote', 'shellpipe', and 'shellredir' options to the
317+
following values:
318+
319+
'shellcmdflag' -Command
320+
'shellxquote' "
321+
'shellpipe' 2>&1 | Out-File -Encoding default
322+
'shellredir' 2>&1 | Out-File -Encoding default
323+
324+
If 'shell' includes "pwsh" in the filename at startup then VIM sets
325+
'shellcmdflag', 'shellxquote', 'shellpipe', and 'shellredir' options to the
326+
following values:
327+
328+
'shellcmdflag' -c
329+
'shellxquote' "
330+
'shellpipe' >%s 2>&1
331+
'shellredir' >%s 2>&1
332+
333+
If you find that PowerShell commands are taking a long time to run then try
334+
with "-NoProfile" at the beginning of the 'shellcmdflag'. Note this will
335+
prevent any PowerShell environment setup by the profile from taking place.
336+
337+
If you have problems running PowerShell scripts through the 'shell' then try
338+
with "-ExecutionPolicy RemoteSigned -Command" at the beginning of
339+
'shellcmdflag'. See online Windows documentation for more information on
340+
PowerShell Execution Policy settings.
341+
342+
See |option-backslash| about including spaces in 'shellcmdflag' when using
343+
multiple flags.
344+
345+
The 'shellpipe' and 'shellredir' option values re-encode the UTF-16le output
346+
from PowerShell Desktop to your currently configured console codepage. The
347+
output can be forced into a different encoding by changing "default" to one of
348+
the following:
349+
350+
unicode - UTF-16le (default output from PowerShell 5.1)
351+
bigendianunicode - UTF-16
352+
utf8 - UTF-8
353+
utf7 - UTF-7 (no BOM)
354+
utf32 - UTF-32
355+
ascii - 7-bit ASCII character set
356+
default - System's active code page (typically ANSI)
357+
oem - System's current OEM code page
358+
359+
Note The abovce multi-byte Unicode encodings include a leading BOM unless
360+
otherwise indicated.
361+
362+
By default PowerShell Core's output is UTF-8 encoded without a BOM. If you
363+
want to force the output of PowerShell Core into a different encoding then set
364+
'shellredir' and 'shellpipe' to "2>&1 | Out-File -Encoding encoding" where
365+
encoding is one of the following:
366+
367+
ascii - 7-bit ASCII character set
368+
bigendianunicode - UTF-16be
369+
bigendianutf32 - UTF-32be
370+
oem - System's current OEM code page
371+
unicode - UTF-16le
372+
utf7 - UTF-7
373+
utf8 - UTF-8
374+
utf8BOM - UTF-8, with BOM
375+
utf8NoBOM - UTF-8, no BOM (default output from PowerShell Core)
376+
utf32 - UTF-32
377+
378+
Since PowerShell Core 6.2, the Encoding parameter also supports specifying a
379+
numeric ID of a registered code page (-Encoding 1251) or string names of
380+
registered code pages (-Encoding "windows-1251"). The .NET documentation for
381+
Encoding.CodePage has more information
303382

304383
vim:tw=78:ts=8:noet:ft=help:norl:

runtime/doc/os_win32.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ File formats |dos-file-formats|
3030
Interrupting |dos-CTRL-Break|
3131
Temp files |dos-temp-files|
3232
Shell option default |dos-shell|
33+
PowerShell defaults |dos-powershell|
3334

3435
Win32 GUI |gui-w32|
3536

runtime/filetype.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
650650
" Gedcom
651651
au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
652652

653+
" Gemtext
654+
au BufNewFile,BufRead *.gmi,*.gemini setf gemtext
655+
653656
" Gift (Moodle)
654657
autocmd BufRead,BufNewFile *.gift setf gift
655658

@@ -868,6 +871,9 @@ au BufNewFile,BufRead *.json-patch setf json
868871
" Jupyter Notebook is also json
869872
au BufNewFile,BufRead *.ipynb setf json
870873

874+
" JSONC
875+
au BufNewFile,BufRead *.jsonc setf jsonc
876+
871877
" Kixtart
872878
au BufNewFile,BufRead *.kix setf kix
873879

src/buffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,12 @@ handle_swap_exists(bufref_T *old_curbuf)
11341134
close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE, FALSE);
11351135
if (old_curbuf == NULL || !bufref_valid(old_curbuf)
11361136
|| old_curbuf->br_buf == curbuf)
1137+
{
1138+
// Block autocommands here because curwin->w_buffer is NULL.
1139+
block_autocmds();
11371140
buf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED);
1141+
unblock_autocmds();
1142+
}
11381143
else
11391144
buf = old_curbuf->br_buf;
11401145
if (buf != NULL)

src/channel.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,12 +2512,17 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
25122512

25132513
if (STRCMP(cmd, "ex") == 0)
25142514
{
2515-
int called_emsg_before = called_emsg;
2515+
int called_emsg_before = called_emsg;
2516+
char_u *p = arg;
2517+
int do_emsg_silent;
25162518

25172519
ch_log(channel, "Executing ex command '%s'", (char *)arg);
2518-
++emsg_silent;
2520+
do_emsg_silent = !checkforcmd(&p, "echoerr", 5);
2521+
if (do_emsg_silent)
2522+
++emsg_silent;
25192523
do_cmdline_cmd(arg);
2520-
--emsg_silent;
2524+
if (do_emsg_silent)
2525+
--emsg_silent;
25212526
if (called_emsg > called_emsg_before)
25222527
ch_log(channel, "Ex command error: '%s'",
25232528
(char *)get_vim_var_str(VV_ERRMSG));
@@ -2571,7 +2576,8 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
25712576
char_u *json = NULL;
25722577

25732578
// Don't pollute the display with errors.
2574-
++emsg_skip;
2579+
// Do generate the errors so that try/catch works.
2580+
++emsg_silent;
25752581
if (!is_call)
25762582
{
25772583
ch_log(channel, "Evaluating expression '%s'", (char *)arg);
@@ -2607,7 +2613,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
26072613
vim_free(json);
26082614
}
26092615
}
2610-
--emsg_skip;
2616+
--emsg_silent;
26112617
if (tv == &res_tv)
26122618
clear_tv(tv);
26132619
else

0 commit comments

Comments
 (0)