Compare commits

...

6 Commits

Author SHA1 Message Date
ola.soder@axis.com
bd89d44063 patch 8.2.4347: in some build setups UNUSED is not defined
Problem:    In some build setups UNUSED is not defined.
Solution:   Change the logic of how UNUSED is defined. (Ola Söder,
            closes #9734)
2022-02-11 19:27:55 +00:00
Bram Moolenaar
481acb1141 patch 8.2.4346: a custom statusline may cause Esc to work like Enter
Problem:    A custom statusline may cause Esc to work like Enter on the
            command line when the popup menu is displayed.
Solution:   Save and restore KeyTyped. (closes #9749)
2022-02-11 18:51:45 +00:00
Bram Moolenaar
f6246f51e3 patch 8.2.4345: <amatch> is expanded like a file name for DirChangedPre
Problem:    <amatch> is expanded like a file name for DirChangedPre.
Solution:   Do not expand <amatch>. (closes #9742)  Also for the User event.
2022-02-11 16:30:12 +00:00
ola.soder@axis.com
14f23122bf patch 8.2.4344: Amiga: header file included twice
Problem:    Amiga: header file included twice.
Solution:   Remove #include. (Ola Söder, closes #9733)
2022-02-11 16:11:14 +00:00
Rob Pilling
8196e94a8b patch 8.2.4343: when reloading not all properties are detected
Problem:    When reloading not all properties are detected.
Solution:   Add the "edit" value to v:fcs_choice. (Rob Pilling, closes #9579)
2022-02-11 15:12:10 +00:00
Bram Moolenaar
92f645bef7 Update runtime files. (closes #9741) 2022-02-11 13:29:40 +00:00
22 changed files with 289 additions and 87 deletions

View File

@@ -1650,6 +1650,11 @@ If you don't get warned often enough you can use the following command.
if it exists now.
Once a file has been checked the timestamp is reset,
you will not be warned again.
Syntax highlighting, marks, diff status,
'fileencoding', 'fileformat' and 'binary' options
are not changed. See |v:fcs_choice| to reload these
too (for example, if a code formatting tools has
changed the file).
:[N]checkt[ime] {filename}
:[N]checkt[ime] [N]

View File

@@ -2070,6 +2070,11 @@ v:fcs_choice What should happen after a |FileChangedShell| event was
do with the affected buffer:
reload Reload the buffer (does not work if
the file was deleted).
edit Reload the buffer and detect the
values for options such as
'fileformat', 'fileencoding', 'binary'
(does not work if the file was
deleted).
ask Ask the user what to do, as if there
was no autocommand. Except that when
only the timestamp changed nothing

View File

@@ -1,4 +1,4 @@
*testing.txt* For Vim version 8.2. Last change: 2022 Feb 04
*testing.txt* For Vim version 8.2. Last change: 2022 Feb 10
VIM REFERENCE MANUAL by Bram Moolenaar

View File

@@ -1,4 +1,4 @@
*todo.txt* For Vim version 8.2. Last change: 2022 Feb 09
*todo.txt* For Vim version 8.2. Last change: 2022 Feb 11
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -38,6 +38,9 @@ browser use: https://github.com/vim/vim/issues/1234
*known-bugs*
-------------------- Known bugs and current work -----------------------
Disallow using "s:" in Vim9 script at the script level.
Disallow a legacy function creating an s: variable in Vim9 script.
Once Vim9 is stable:
- Use Vim9 for runtime files.
- Check code coverage, add more tests if needed.

View File

@@ -1,4 +1,4 @@
*usr_41.txt* For Vim version 8.2. Last change: 2022 Jan 28
*usr_41.txt* For Vim version 8.2. Last change: 2022 Feb 11
VIM USER MANUAL - by Bram Moolenaar
@@ -2512,6 +2512,8 @@ continuation, as mentioned above |use-cpo-save|.
For undoing the effect of an indent script, the b:undo_indent variable should
be set accordingly.
Both these variables use legacy script syntax, not |Vim9| syntax.
FILE NAME

View File

@@ -1,4 +1,4 @@
*vim9.txt* For Vim version 8.2. Last change: 2022 Feb 09
*vim9.txt* For Vim version 8.2. Last change: 2022 Feb 11
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -219,20 +219,18 @@ be given.
Functions and variables are script-local by default ~
*vim9-scopes*
When using `:function` or `:def` to specify a new function at the script level
in a Vim9 script, the function is local to the script, as if "s:" was
prefixed. Using the "s:" prefix is optional. To define a global function or
variable the "g:" prefix must be used. For functions in a script that is to
be imported and in an autoload script "export" needs to be used. >
in a Vim9 script, the function is local to the script. Like prefixing "s:" in
legacy script. To define a global function or variable the "g:" prefix must
be used. For functions in a script that is to be imported and in an autoload
script "export" needs to be used. >
def ThisFunction() # script-local
def s:ThisFunction() # script-local
def g:ThatFunction() # global
export def Function() # for import and import autoload
< *E1058* *E1075*
When using `:function` or `:def` to specify a nested function inside a `:def`
function and no namespace was given, this nested function is local to the code
block it is defined in. In a `:def` function it is not possible to define a
script-local function. It is possible to define a global function by using
the "g:" prefix.
block it is defined in. It is not possible to define a script-local function.
It is possible to define a global function by using the "g:" prefix.
When referring to a function and no "s:" or "g:" prefix is used, Vim will
search for the function:
@@ -244,6 +242,13 @@ start with an upper case letter even when using the "s:" prefix. In legacy
script "s:funcref" could be used, because it could not be referred to with
"funcref". In Vim9 script it can, therefore "s:Funcref" must be used to avoid
that the name interferes with builtin functions.
*vim9-s-namespace*
The use of the "s:" prefix is not supported at the Vim9 script level. All
functions and variables without a prefix are script-local.
In :def functions the use of "s:" is optional. This is because in legacy
script the "s:" might be needed. Disallowing the use of "s:" only in a :def
function in Vim9 script would be a bit confusing.
In legacy functions the use of "s:" for script items is required, as before.
In all cases the function must be defined before used. That is when it is
called, when `:defcompile` causes it to be compiled, or when code that calls

View File

@@ -3,7 +3,7 @@ vim9script noclear
# Vim support file to switch on loading plugins for file types
#
# Maintainer: Bram Moolenaar <Bram@vim.org>
# Last change: 2022 Feb 09
# Last change: 2022 Feb 11
if exists("g:did_load_ftplugin")
finish
@@ -21,7 +21,8 @@ endif
def LoadFTPlugin()
if exists("b:undo_ftplugin")
exe b:undo_ftplugin
# We assume b:undo_ftplugin is using legacy script syntax
legacy exe b:undo_ftplugin
unlet! b:undo_ftplugin b:did_ftplugin
endif

View File

@@ -1,7 +1,7 @@
" Vim support file to switch on loading indent files for file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2022 Feb 04
" Last Change: 2022 Feb 11
if exists("did_indent_on")
finish
@@ -14,7 +14,7 @@ augroup END
def s:LoadIndent()
if exists("b:undo_indent")
exe b:undo_indent
legacy exe b:undo_indent
unlet! b:undo_indent b:did_indent
endif
var s = expand("<amatch>")

View File

@@ -7,51 +7,57 @@
" Attached is a Vim script file for turning gvim into a shell script editor.
" It may also be used as an example how to use menus in Vim.
"
" Written by: Lennart Schultz <les@dmi.min.dk>
" Maintainer: Ada (Haowen) Yu <me@yuhaowen.com>
" Original author: Lennart Schultz <les@dmi.min.dk> (mail unreachable)
imenu Stmts.for for in
do
doneki kk0elli
imenu Stmts.case case in
) ;;
" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
" <CR> would not be recognized. See ":help 'cpoptions'".
let s:cpo_save = &cpo
set cpo&vim
imenu Stmts.for for in <CR>do<CR><CR>done<esc>ki <esc>kk0elli
imenu Stmts.case case in<CR>) ;;<CR>esac<esc>bki <esc>k0elli
imenu Stmts.if if <CR>then<CR><CR>fi<esc>ki <esc>kk0elli
imenu Stmts.if-else if <CR>then<CR><CR>else<CR><CR>fi<esc>ki <esc>kki <esc>kk0elli
imenu Stmts.elif elif <CR>then<CR><CR><esc>ki <esc>kk0elli
imenu Stmts.while while do<CR><CR>done<esc>ki <esc>kk0elli
imenu Stmts.break break
imenu Stmts.continue continue
then
imenu Stmts.function () {<CR><CR>}<esc>ki <esc>k0i
imenu Stmts.return return
imenu Stmts.return-true return 0
imenu Stmts.return-false return 1
imenu Stmts.exit exit
imenu Stmts.shift shift
imenu Stmts.trap trap
fiki kki kk0elli
imenu Stmts.elif elif
then
ki kk0elli
imenu Stmts.while while
do
doneki kk0elli
imenu Stmts.break break
imenu Stmts.continue continue
imenu Stmts.function () {
}ki k0i
imenu Stmts.return return
imenu Stmts.return-true return 0
imenu Stmts.return-false return 1
imenu Stmts.exit exit
imenu Stmts.shift shift
imenu Stmts.trap trap
imenu Test.existence [ -e ]hi
imenu Test.existence - file [ -f ]hi
imenu Test.existence - file (not empty) [ -s ]hi
imenu Test.existence - directory [ -d ]hi
imenu Test.existence - executable [ -x ]hi
imenu Test.existence - readable [ -r ]hi
imenu Test.existence - writable [ -w ]hi
imenu Test.existence [ -e ]<esc>hi
imenu Test.existence\ -\ file [ -f ]<esc>hi
imenu Test.existence\ -\ file\ (not\ empty) [ -s ]<esc>hi
imenu Test.existence\ -\ directory [ -d ]<esc>hi
imenu Test.existence\ -\ executable [ -x ]<esc>hi
imenu Test.existence\ -\ readable [ -r ]<esc>hi
imenu Test.existence\ -\ writable [ -w ]<esc>hi
imenu Test.String\ is\ empty [ x = "x$" ]<esc>hhi
imenu Test.String\ is\ not\ empty [ x != "x$" ]<esc>hhi
imenu Test.Strings\ is\ equal [ "" = "" ]<esc>hhhhhhhi
imenu Test.Strings\ is\ not\ equal [ "" != "" ]<esc>hhhhhhhhi
imenu Test.Values\ is\ greater\ than [ -gt ]<esc>hhhhhhi
imenu Test.Values\ is\ greater\ equal [ -ge ]<esc>hhhhhhi
imenu Test.Values\ is\ equal [ -eq ]<esc>hhhhhhi
imenu Test.Values\ is\ not\ equal [ -ne ]<esc>hhhhhhi
imenu Test.Values\ is\ less\ than [ -lt ]<esc>hhhhhhi
imenu Test.Values\ is\ less\ equal [ -le ]<esc>hhhhhhi
imenu ParmSub.Substitute\ word\ if\ parm\ not\ set ${:-}<esc>hhi
imenu ParmSub.Set\ parm\ to\ word\ if\ not\ set ${:=}<esc>hhi
imenu ParmSub.Substitute\ word\ if\ parm\ set\ else\ nothing ${:+}<esc>hhi
imenu ParmSub.If\ parm\ not\ set\ print\ word\ and\ exit ${:?}<esc>hhi
imenu SpShVars.Number\ of\ positional\ parameters ${#}
imenu SpShVars.All\ positional\ parameters\ (quoted\ spaces) ${*}
imenu SpShVars.All\ positional\ parameters\ (unquoted\ spaces) ${@}
imenu SpShVars.Flags\ set ${-}
imenu SpShVars.Return\ code\ of\ last\ command ${?}
imenu SpShVars.Process\ number\ of\ this\ shell ${$}
imenu SpShVars.Process\ number\ of\ last\ background\ command ${!}
imenu Environ.HOME ${HOME}
imenu Environ.PATH ${PATH}
imenu Environ.CDPATH ${CDPATH}
@@ -82,13 +88,17 @@ imenu Builtins.umask umask
imenu Builtins.wait wait
imenu Set.set set
imenu Set.unset unset
imenu Environ.SHELL ${SHELL}
imenu Environ.LC_CTYPE ${LC_CTYPE}
imenu Environ.LC_MESSAGES ${LC_MESSAGES}
imenu Builtins.cd cd
imenu Builtins.echo echo
imenu Builtins.eval eval
imenu Builtins.exec exec
imenu Builtins.export export
imenu Builtins.getopts getopts
imenu Builtins.hash hash
imenu Set.mark\ modified\ or\ modified\ variables set -a
imenu Set.exit\ when\ command\ returns\ non-zero\ exit\ code set -e
imenu Set.Disable\ file\ name\ generation set -f
imenu Set.remember\ function\ commands set -h
imenu Set.All\ keyword\ arguments\ are\ placed\ in\ the\ environment set -k
imenu Set.Read\ commands\ but\ do\ not\ execute\ them set -n
imenu Set.Exit\ after\ reading\ and\ executing\ one\ command set -t
imenu Set.Treat\ unset\ variables\ as\ an\ error\ when\ substituting set -u
imenu Set.Print\ shell\ input\ lines\ as\ they\ are\ read set -v
imenu Set.Print\ commands\ and\ their\ arguments\ as\ they\ are\ executed set -x
" Restore the previous value of 'cpoptions'.
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@@ -2043,7 +2043,7 @@ apply_autocmds_group(
{
sfname = vim_strsave(fname);
// Don't try expanding FileType, Syntax, FuncUndefined, WindowID,
// ColorScheme, QuickFixCmd* or DirChanged
// ColorScheme, QuickFixCmd*, DirChanged and similar.
if (event == EVENT_FILETYPE
|| event == EVENT_SYNTAX
|| event == EVENT_CMDLINECHANGED
@@ -2061,7 +2061,9 @@ apply_autocmds_group(
|| event == EVENT_OPTIONSET
|| event == EVENT_QUICKFIXCMDPOST
|| event == EVENT_DIRCHANGED
|| event == EVENT_DIRCHANGEDPRE
|| event == EVENT_MODECHANGED
|| event == EVENT_USER
|| event == EVENT_WINCLOSED)
{
fname = vim_strsave(fname);

View File

@@ -571,6 +571,7 @@ redraw_custom_statusline(win_T *wp)
{
static int entered = FALSE;
int saved_did_emsg = did_emsg;
int saved_KeyTyped = KeyTyped;
// When called recursively return. This can happen when the statusline
// contains an expression that triggers a redraw.
@@ -591,6 +592,9 @@ redraw_custom_statusline(win_T *wp)
}
did_emsg |= saved_did_emsg;
entered = FALSE;
// A user function may reset KeyTyped, restore it.
KeyTyped = saved_KeyTyped;
}
#endif

View File

@@ -2697,7 +2697,7 @@ readfile_linenr(
}
/*
* Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be
* Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary' to be
* equal to the buffer "buf". Used for calling readfile().
* Returns OK or FAIL.
*/
@@ -4041,7 +4041,11 @@ buf_check_timestamp(
char *mesg = NULL;
char *mesg2 = "";
int helpmesg = FALSE;
int reload = FALSE;
enum {
RELOAD_NONE,
RELOAD_NORMAL,
RELOAD_DETECT
} reload = RELOAD_NONE;
char *reason;
#if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
int can_reload = FALSE;
@@ -4117,7 +4121,7 @@ buf_check_timestamp(
*/
else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
&& !bufIsChanged(buf) && stat_res >= 0)
reload = TRUE;
reload = RELOAD_NORMAL;
else
{
if (stat_res < 0)
@@ -4158,7 +4162,9 @@ buf_check_timestamp(
#ifdef FEAT_EVAL
s = get_vim_var_str(VV_FCS_CHOICE);
if (STRCMP(s, "reload") == 0 && *reason != 'd')
reload = TRUE;
reload = RELOAD_NORMAL;
else if (STRCMP(s, "edit") == 0)
reload = RELOAD_DETECT;
else if (STRCMP(s, "ask") == 0)
n = FALSE;
else
@@ -4239,10 +4245,18 @@ buf_check_timestamp(
STRCAT(tbuf, "\n");
STRCAT(tbuf, mesg2);
}
if (do_dialog(VIM_WARNING, (char_u *)_("Warning"),
(char_u *)tbuf,
(char_u *)_("&OK\n&Load File"), 1, NULL, TRUE) == 2)
reload = TRUE;
switch (do_dialog(VIM_WARNING, (char_u *)_("Warning"),
(char_u *)tbuf,
(char_u *)_("&OK\n&Load File\nLoad File &and Options"),
1, NULL, TRUE))
{
case 2:
reload = RELOAD_NORMAL;
break;
case 3:
reload = RELOAD_DETECT;
break;
}
}
else
#endif
@@ -4287,10 +4301,10 @@ buf_check_timestamp(
}
}
if (reload)
if (reload != RELOAD_NONE)
{
// Reload the buffer.
buf_reload(buf, orig_mode);
buf_reload(buf, orig_mode, reload == RELOAD_DETECT);
#ifdef FEAT_PERSISTENT_UNDO
if (buf->b_p_udf && buf->b_ffname != NULL)
{
@@ -4326,7 +4340,7 @@ buf_check_timestamp(
* buf->b_orig_mode may have been reset already.
*/
void
buf_reload(buf_T *buf, int orig_mode)
buf_reload(buf_T *buf, int orig_mode, int reload_options)
{
exarg_T ea;
pos_T old_cursor;
@@ -4337,14 +4351,20 @@ buf_reload(buf_T *buf, int orig_mode)
int saved = OK;
aco_save_T aco;
int flags = READ_NEW;
int prepped = OK;
// set curwin/curbuf for "buf" and save some things
aucmd_prepbuf(&aco, buf);
// We only want to read the text from the file, not reset the syntax
// highlighting, clear marks, diff status, etc. Force the fileformat
// and encoding to be the same.
if (prep_exarg(&ea, buf) == OK)
// Unless reload_options is set, we only want to read the text from the
// file, not reset the syntax highlighting, clear marks, diff status, etc.
// Force the fileformat and encoding to be the same.
if (reload_options)
memset(&ea, 0, sizeof(ea));
else
prepped = prep_exarg(&ea, buf);
if (prepped == OK)
{
old_cursor = curwin->w_cursor;
old_topline = curwin->w_topline;

View File

@@ -57,7 +57,6 @@
extern int dos2; // this is in os_amiga.c
# endif
# ifdef SASC
# include <proto/dos.h>
# include <ios1.h> // for chkufb()
# endif
#endif

View File

@@ -3752,6 +3752,8 @@ msg_advance(int col)
* Other buttons- use your imagination!
* A '&' in a button name becomes a shortcut, so each '&' should be before a
* different letter.
*
* Returns 0 if cancelled, otherwise the nth button (1-indexed).
*/
int
do_dialog(

View File

@@ -28,7 +28,7 @@ int vim_fgets(char_u *buf, int size, FILE *fp);
int vim_rename(char_u *from, char_u *to);
int check_timestamps(int focus);
int buf_check_timestamp(buf_T *buf, int focus);
void buf_reload(buf_T *buf, int orig_mode);
void buf_reload(buf_T *buf, int orig_mode, int reload_options);
void buf_store_time(buf_T *buf, stat_T *st, char_u *fname);
void write_lnum_adjust(linenr_T offset);
int readdir_core(garray_T *gap, char_u *path, int withattr, void *context, int (*checkitem)(void *context, void *item), int sort);

View File

@@ -6336,7 +6336,7 @@ spell_add_word(
// If the .add file is edited somewhere, reload it.
if (buf != NULL)
buf_reload(buf, buf->b_orig_mode);
buf_reload(buf, buf->b_orig_mode, FALSE);
redraw_all_later(SOME_VALID);
}

View File

@@ -0,0 +1,10 @@
> +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|s+3#0000000&|t|a|t|u|s| @68
| +0&&@74

View File

@@ -1899,6 +1899,14 @@ func Test_autocommand_all_events()
call assert_fails('au! * x bwipe', 'E1155:')
endfunc
func Test_autocmd_user()
au User MyEvent let s:res = [expand("<afile>"), expand("<amatch>")]
doautocmd User MyEvent
call assert_equal(['MyEvent', 'MyEvent'], s:res)
au! User
unlet s:res
endfunc
function s:Before_test_dirchanged()
augroup test_dirchanged
autocmd!
@@ -1922,11 +1930,11 @@ endfunc
function Test_dirchanged_global()
call s:Before_test_dirchanged()
autocmd test_dirchanged DirChangedPre global call add(s:li, "pre cd " .. v:event.directory)
autocmd test_dirchanged DirChangedPre global call add(s:li, expand("<amatch>") .. " pre cd " .. v:event.directory)
autocmd test_dirchanged DirChanged global call add(s:li, "cd:")
autocmd test_dirchanged DirChanged global call add(s:li, expand("<afile>"))
call chdir(s:dir_foo)
let expected = ["pre cd " .. s:dir_foo, "cd:", s:dir_foo]
let expected = ["global pre cd " .. s:dir_foo, "cd:", s:dir_foo]
call assert_equal(expected, s:li)
call chdir(s:dir_foo)
call assert_equal(expected, s:li)

View File

@@ -1983,6 +1983,14 @@ func Test_wildmenu_pum()
return repeat(['aaaa'], 120)
endfunc
command -nargs=* -complete=customlist,CmdCompl Tcmd
func MyStatusLine() abort
return 'status'
endfunc
func SetupStatusline()
set statusline=%!MyStatusLine()
set laststatus=2
endfunc
[CODE]
call writefile(commands, 'Xtest')
@@ -2166,6 +2174,13 @@ func Test_wildmenu_pum()
call term_sendkeys(buf, ":ls\<CR>")
call term_sendkeys(buf, ":com\<Tab> ")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_38', {})
call term_sendkeys(buf, "\<C-U>\<CR>")
" Esc still works to abort the command when 'statusline' is set
call term_sendkeys(buf, ":call SetupStatusline()\<CR>")
call term_sendkeys(buf, ":si\<Tab>")
call term_sendkeys(buf, "\<Esc>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_39', {})
call term_sendkeys(buf, "\<C-U>\<CR>")
call StopVimInTerminal(buf)

View File

@@ -91,6 +91,100 @@ func Test_FileChangedShell_reload()
call delete('Xchanged_r')
endfunc
func Test_FileChangedShell_edit()
CheckUnix
new Xchanged_r
call setline(1, 'reload this')
set fileformat=unix
write
" File format changed, reload (content only, no 'ff' etc)
augroup testreload
au!
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'reload'
augroup END
call assert_equal(&fileformat, 'unix')
call writefile(["line1\r", "line2\r"], 'Xchanged_r')
let g:reason = ''
checktime
call assert_equal('changed', g:reason)
call assert_equal(&fileformat, 'unix')
call assert_equal("line1\r", getline(1))
call assert_equal("line2\r", getline(2))
%s/\r
write
" File format changed, reload with 'ff', etc
augroup testreload
au!
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'edit'
augroup END
call assert_equal(&fileformat, 'unix')
call writefile(["line1\r", "line2\r"], 'Xchanged_r')
let g:reason = ''
checktime
call assert_equal('changed', g:reason)
call assert_equal(&fileformat, 'dos')
call assert_equal('line1', getline(1))
call assert_equal('line2', getline(2))
set fileformat=unix
write
au! testreload
bwipe!
call delete(undofile('Xchanged_r'))
call delete('Xchanged_r')
endfunc
func Test_FileChangedShell_edit_dialog()
CheckNotGui
new Xchanged_r
call setline(1, 'reload this')
set fileformat=unix
write
" File format changed, reload (content only) via prompt
augroup testreload
au!
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask'
augroup END
call assert_equal(&fileformat, 'unix')
call writefile(["line1\r", "line2\r"], 'Xchanged_r')
let g:reason = ''
call feedkeys('L', 'L') " load file content only
checktime
call assert_equal('changed', g:reason)
call assert_equal(&fileformat, 'unix')
call assert_equal("line1\r", getline(1))
call assert_equal("line2\r", getline(2))
%s/\r
write
" File format changed, reload (file and options) via prompt
augroup testreload
au!
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask'
augroup END
call assert_equal(&fileformat, 'unix')
call writefile(["line1\r", "line2\r"], 'Xchanged_r')
let g:reason = ''
call feedkeys('a', 'L') " load file content and options
checktime
call assert_equal('changed', g:reason)
call assert_equal(&fileformat, 'dos')
call assert_equal("line1", getline(1))
call assert_equal("line2", getline(2))
set fileformat=unix
write
au! testreload
bwipe!
call delete(undofile('Xchanged_r'))
call delete('Xchanged_r')
endfunc
func Test_file_changed_dialog()
CheckUnix
CheckNotGui

View File

@@ -746,6 +746,16 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4347,
/**/
4346,
/**/
4345,
/**/
4344,
/**/
4343,
/**/
4342,
/**/

View File

@@ -245,12 +245,19 @@
// Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
// can be used to check for mistakes.
#if defined(HAVE_ATTRIBUTE_UNUSED) || defined(__MINGW32__)
# if !defined(UNUSED)
#ifndef UNUSED
# if defined(HAVE_ATTRIBUTE_UNUSED) || defined(__MINGW32__)
# define UNUSED __attribute__((unused))
# else
# if defined __has_attribute
# if __has_attribute(unused)
# define UNUSED __attribute__((unused))
# endif
# endif
# endif
# ifndef UNUSED
# define UNUSED
# endif
#else
# define UNUSED
#endif
// Used to check for "sun", "__sun" is used by newer compilers.