From 77771d33f44bfb9f75eb857bd2f2bb4c2860cac3 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 13 Apr 2022 11:47:25 +0100 Subject: [PATCH 01/25] patch 8.2.4744: a terminal window can't use the bell Problem: A terminal window can't use the bell. Solution: Add bell support for the terminal window. (closes #10178) --- runtime/doc/options.txt | 2 ++ src/gui_w32.c | 2 +- src/option.h | 3 ++- src/optionstr.c | 2 +- src/terminal.c | 12 +++++++++++- src/version.c | 2 ++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index ddd5af08ed..2ed4a8f31a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1265,6 +1265,7 @@ A jump table for the options with a short description can be found at |Q_op|. separated list of items. For each item that is present, the bell will be silenced. This is most useful to specify specific events in insert mode to be silenced. + You can also make it flash by using 'visualbell'. item meaning when present ~ all All events. @@ -1290,6 +1291,7 @@ A jump table for the options with a short description can be found at |Q_op|. register Unknown register after in |Insert-mode|. shell Bell from shell output |:!|. spell Error happened on spell suggest. + term Bell from |:terminal| output. wildmode More matches in |cmdline-completion| available (depends on the 'wildmode' setting). diff --git a/src/gui_w32.c b/src/gui_w32.c index d1cc06d5b9..35cb2d26a2 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -1696,7 +1696,7 @@ gui_mch_haskey(char_u *name) void gui_mch_beep(void) { - MessageBeep(MB_OK); + MessageBeep((UINT)-1); } /* * Invert a rectangle from row r, column c, for nr rows and nc columns. diff --git a/src/option.h b/src/option.h index 4c583a48ff..936f260e83 100644 --- a/src/option.h +++ b/src/option.h @@ -451,7 +451,8 @@ EXTERN unsigned bo_flags; #define BO_REG 0x8000 #define BO_SH 0x10000 #define BO_SPELL 0x20000 -#define BO_WILD 0x40000 +#define BO_TERM 0x40000 +#define BO_WILD 0x80000 #ifdef FEAT_WILDIGN EXTERN char_u *p_bsk; // 'backupskip' diff --git a/src/optionstr.c b/src/optionstr.c index fd72da4df6..2accd3d27f 100644 --- a/src/optionstr.c +++ b/src/optionstr.c @@ -20,7 +20,7 @@ static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete", "copy", "ctrlg", "error", "esc", "ex", "hangul", "insertmode", "lang", "mess", "showmatch", "operator", "register", "shell", - "spell", "wildmode", NULL}; + "spell", "term", "wildmode", NULL}; static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", "unsigned", NULL}; static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL}; #ifdef FEAT_CRYPT diff --git a/src/terminal.c b/src/terminal.c index b6efb493e7..9f9e84ac3a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -3385,12 +3385,22 @@ handle_postponed_scrollback(term_T *term) limit_scrollback(term, &term->tl_scrollback, TRUE); } +/* + * Called when the terminal wants to ring the system bell. + */ + static int +handle_bell(void *user UNUSED) +{ + vim_beep(BO_SH); + return 0; +} + static VTermScreenCallbacks screen_callbacks = { handle_damage, // damage handle_moverect, // moverect handle_movecursor, // movecursor handle_settermprop, // settermprop - NULL, // bell + handle_bell, // bell handle_resize, // resize handle_pushline, // sb_pushline NULL // sb_popline diff --git a/src/version.c b/src/version.c index 5c8bd2acdf..584410a92a 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4744, /**/ 4743, /**/ From aae9762b2cbcae8dea454e1701d00ea0f614175e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Apr 2022 14:28:07 +0100 Subject: [PATCH 02/25] patch 8.2.4745: using wrong flag for using bell in the terminal Problem: Using wrong flag for using bell in the terminal. Solution: Change to use BO_TERM. --- src/misc1.c | 5 ++--- src/terminal.c | 2 +- src/version.c | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/misc1.c b/src/misc1.c index 82dbbba6e6..6dbad3fc73 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -1095,11 +1095,10 @@ beep_flush(void) } /* - * Give a warning for an error. + * Give a warning for an error. "val" is one of the BO_ values, e.g., BO_OPER. */ void -vim_beep( - unsigned val) // one of the BO_ values, e.g., BO_OPER +vim_beep(unsigned val) { #ifdef FEAT_EVAL called_vim_beep = TRUE; diff --git a/src/terminal.c b/src/terminal.c index 9f9e84ac3a..658d5e0b91 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -3391,7 +3391,7 @@ handle_postponed_scrollback(term_T *term) static int handle_bell(void *user UNUSED) { - vim_beep(BO_SH); + vim_beep(BO_TERM); return 0; } diff --git a/src/version.c b/src/version.c index 584410a92a..7a8f52f7a7 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4745, /**/ 4744, /**/ From 8cac20ed42b7b7fc9c6b54e3055ca1047f50b8ca Mon Sep 17 00:00:00 2001 From: ranjithshegde Date: Wed, 13 Apr 2022 15:29:21 +0100 Subject: [PATCH 03/25] patch 8.2.4746: supercollider filetype not recognized Problem: Supercollider filetype not recognized. Solution: Match file extentions and check file contents to detect supercollider. (closes #10142) --- runtime/autoload/dist/ft.vim | 22 +++++++++++++++ runtime/filetype.vim | 18 ++++++++---- src/testdir/test_filetype.vim | 52 +++++++++++++++++++++++++++++++++-- src/version.c | 2 ++ 4 files changed, 86 insertions(+), 8 deletions(-) diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 3bf552a1a5..ff554dfe83 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -769,6 +769,28 @@ export def SQL() endif enddef +# This function checks the first 25 lines of file extension "sc" to resolve +# detection between scala and SuperCollider +export def FTsc() + for lnum in range(1, min([line("$"), 25])) + if getline(lnum) =~# '[A-Za-z0-9]*\s:\s[A-Za-z0-9]\|var\s<\|classvar\s<\|\^this.*\||\w*|\|+\s\w*\s{\|\*ar\s' + setf supercollider + return + endif + endfor + setf scala +enddef + +# This function checks the first line of file extension "scd" to resolve +# detection between scdoc and SuperCollider +export def FTscd() + if getline(1) =~# '\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$' + setf scdoc + else + setf supercollider + endif +enddef + # If the file has an extension of 't' and is in a directory 't' or 'xt' then # it is almost certainly a Perl test file. # If the first line starts with '#' and contains 'perl' it's probably a Perl diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 62afb375cb..500f469236 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -206,12 +206,12 @@ au BufNewFile,BufRead *.iba,*.ibi setf ibasic au BufNewFile,BufRead *.fb setf freebasic " Batch file for MSDOS. See dist#ft#FTsys for *.sys -au BufNewFile,BufRead *.bat setf dosbatch +au BufNewFile,BufRead *.bat setf dosbatch " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. au BufNewFile,BufRead *.cmd \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif " ABB RAPID or Batch file for MSDOS. -au BufNewFile,BufRead *.sys\c call dist#ft#FTsys() +au BufNewFile,BufRead *.sys\c call dist#ft#FTsys() " Batch file for 4DOS au BufNewFile,BufRead *.btm call dist#ft#FTbtm() @@ -1144,7 +1144,7 @@ au BufNewFile,BufRead *.mms call dist#ft#FTmms() au BufNewFile,BufRead *.mmp setf mmp " ABB Rapid, Modula-2, Modsim III or LambdaProlog -au BufNewFile,BufRead *.mod\c call dist#ft#FTmod() +au BufNewFile,BufRead *.mod\c call dist#ft#FTmod() " Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD) au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2 @@ -1634,16 +1634,22 @@ au BufNewFile,BufRead *.sass setf sass au BufNewFile,BufRead *.sa setf sather " Scala -au BufNewFile,BufRead *.scala,*.sc setf scala +au BufNewFile,BufRead *.scala setf scala " SBT - Scala Build Tool au BufNewFile,BufRead *.sbt setf sbt +" SuperCollider +au BufNewFile,BufRead *.sc call dist#ft#FTsc() + +au BufNewFile,BufRead *.quark setf supercollider + +" scdoc +au BufNewFile,BufRead *.scd call dist#ft#FTscd() + " Scilab au BufNewFile,BufRead *.sci,*.sce setf scilab -" scdoc -au BufNewFile,BufRead *.scd setf scdoc " SCSS au BufNewFile,BufRead *.scss setf scss diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index a609de784d..34868d6014 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -464,12 +464,11 @@ let s:filename_checks = { \ 'sass': ['file.sass'], \ 'sather': ['file.sa'], \ 'sbt': ['file.sbt'], - \ 'scala': ['file.scala', 'file.sc'], + \ 'scala': ['file.scala'], \ 'scheme': ['file.scm', 'file.ss', 'file.sld', 'file.rkt', 'file.rktd', 'file.rktl'], \ 'scilab': ['file.sci', 'file.sce'], \ 'screen': ['.screenrc', 'screenrc'], \ 'sexplib': ['file.sexp'], - \ 'scdoc': ['file.scd'], \ 'scss': ['file.scss'], \ 'sd': ['file.sd'], \ 'sdc': ['file.sdc'], @@ -517,6 +516,7 @@ let s:filename_checks = { \ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'], \ 'stp': ['file.stp'], \ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp', '/etc/sudoers', 'any/etc/sudoers.d/file'], + \ 'supercollider': ['file.quark'], \ 'surface': ['file.sface'], \ 'svg': ['file.svg'], \ 'svn': ['svn-commitfile.tmp', 'svn-commit-file.tmp', 'svn-commit.tmp'], @@ -1497,6 +1497,54 @@ func Test_prg_file() filetype off endfunc +" Test dist#ft#FTsc() +func Test_sc_file() + filetype on + + " SC file mehtods are defined 'Class : Method' + call writefile(['SCNvimDocRenderer : SCDocHTMLRenderer {'], 'srcfile.sc') + split srcfile.sc + call assert_equal('supercollider', &filetype) + bwipe! + call delete('srcfile.sc') + + " SC classes are defined with '+ Class {}' + call writefile(['+ SCNvim {', '*methodArgs {|method|'], 'srcfile.sc') + split srcfile.sc + call assert_equal('supercollider', &filetype) + bwipe! + call delete('srcfile.sc') + + " Some SC class files start with comment and define methods many lines later + call writefile(['// Query', '//Method','^this {'], 'srcfile.sc') + split srcfile.sc + call assert_equal('supercollider', &filetype) + bwipe! + call delete('srcfile.sc') + + " Some SC class files put comments between method declaration after class + call writefile(['PingPong {', '//comment','*ar { arg'], 'srcfile.sc') + split srcfile.sc + call assert_equal('supercollider', &filetype) + bwipe! + call delete('srcfile.sc') + + filetype off +endfunc + +" Test dist#ft#FTscd() +func Test_scd_file() + filetype on + + call writefile(['ijq(1)'], 'srcfile.scd') + split srcfile.scd + call assert_equal('scdoc', &filetype) + bwipe! + call delete('srcfile.scd') + + filetype off +endfunc + func Test_src_file() filetype on diff --git a/src/version.c b/src/version.c index 7a8f52f7a7..e3ba0c89fe 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4746, /**/ 4745, /**/ From f420ff2440a009acd9573fdb6ad6d53509d78009 Mon Sep 17 00:00:00 2001 From: KnoP-01 Date: Wed, 13 Apr 2022 20:46:21 +0100 Subject: [PATCH 04/25] patch 8.2.4747: no filetype override for .sys files Problem: No filetype override for .sys files. Solution: Add g:filetype_sys. (Patrick Meiser-Knosowski, closes #10181) --- runtime/autoload/dist/ft.vim | 4 +++- runtime/doc/filetype.txt | 1 + src/testdir/test_filetype.vim | 9 ++++++++- src/version.c | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index ff554dfe83..4c2d20ae71 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -819,7 +819,9 @@ export def FTperl(): number enddef export def FTsys() - if IsRapid() + if exists("g:filetype_sys") + exe "setf " .. g:filetype_sys + elseif IsRapid() setf rapid else setf bat diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index b921c3db08..f538329dfe 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -155,6 +155,7 @@ variables can be used to overrule the filetype used for certain extensions: *.pp g:filetype_pp |ft-pascal-syntax| *.prg g:filetype_prg *.src g:filetype_src + *.sys g:filetype_sys *.sh g:bash_is_sh |ft-sh-syntax| *.tex g:tex_flavor |ft-tex-plugin| *.w g:filetype_w |ft-cweb-syntax| diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 34868d6014..a94002e086 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -1501,7 +1501,7 @@ endfunc func Test_sc_file() filetype on - " SC file mehtods are defined 'Class : Method' + " SC file methods are defined 'Class : Method' call writefile(['SCNvimDocRenderer : SCDocHTMLRenderer {'], 'srcfile.sc') split srcfile.sc call assert_equal('supercollider', &filetype) @@ -1588,6 +1588,13 @@ func Test_sys_file() call assert_equal('bat', &filetype) bwipe! + " Users preference set by g:filetype_sys + let g:filetype_sys = 'sys' + split sysfile.sys + call assert_equal('sys', &filetype) + unlet g:filetype_sys + bwipe! + " RAPID header start with a line containing only "%%%", " but is not always present. call writefile(['%%%'], 'sysfile.sys') diff --git a/src/version.c b/src/version.c index e3ba0c89fe..9f9917726f 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4747, /**/ 4746, /**/ From 8944551534b311a2d25acf6e8db235c6d906256c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2022 12:58:23 +0100 Subject: [PATCH 05/25] patch 8.2.4748: cannot use an imported function in a mapping Problem: Cannot use an imported function in a mapping. Solution: Recognize name.Func. --- runtime/doc/vim9.txt | 10 ++++++++- src/proto/vim9execute.pro | 1 + src/scriptfile.c | 14 +++++++++++- src/term.c | 23 ++++++++++++++++--- src/testdir/test_vim9_import.vim | 36 +++++++++++++++++++++++++++--- src/version.c | 2 ++ src/vim9execute.c | 38 +++++++++++++++++++++++--------- 7 files changed, 105 insertions(+), 19 deletions(-) diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 5020bcf90b..b30e5f3d4a 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1720,7 +1720,15 @@ line, there can be no line break: > name # Error! echo that .name # Error! -< *:import-cycle* + +To refer to a function in an imported script in a mapping, || can be +used: > + noremap ,a :call name.Function() + +When the mapping is defined "name." will be replaced with and the +script ID of the imported script. + + *:import-cycle* The `import` commands are executed when encountered. If script A imports script B, and B (directly or indirectly) imports A, this will be skipped over. At this point items in A after "import B" will not have been processed and diff --git a/src/proto/vim9execute.pro b/src/proto/vim9execute.pro index bd67092915..80afb8536a 100644 --- a/src/proto/vim9execute.pro +++ b/src/proto/vim9execute.pro @@ -6,6 +6,7 @@ int set_ref_in_funcstacks(int copyID); char_u *char_from_string(char_u *str, varnumber_T index); char_u *string_slice(char_u *str, varnumber_T first, varnumber_T last, int exclusive); int fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx); +int may_load_script(int sid, int *loaded); typval_T *lookup_debug_var(char_u *name); int may_break_in_function(ufunc_T *ufunc); int exe_typval_instr(typval_T *tv, typval_T *rettv); diff --git a/src/scriptfile.c b/src/scriptfile.c index 7e14cdc6e3..2a1f84a50e 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -117,7 +117,7 @@ estack_pop(void) } /* - * Get the current value for in allocated memory. + * Get the current value for "which" in allocated memory. * "which" is ESTACK_SFILE for , ESTACK_STACK for or * ESTACK_SCRIPT for