annotate runtime/ftplugin/julia.vim @ 34379:37b4c89ba420 v9.1.0116

patch 9.1.0116: win_split_ins may not check available room Commit: https://github.com/vim/vim/commit/0fd44a5ad81ade342cb54d8984965bdedd2272c8 Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Tue Feb 20 20:28:15 2024 +0100 patch 9.1.0116: win_split_ins may not check available room Problem: win_split_ins has no check for E36 when moving an existing window Solution: check for room and fix the issues in f_win_splitmove() (Sean Dewar) win_split_ins has no check for E36 when moving an existing window, allowing for layouts with many overlapping zero-sized windows to be created (which may also cause drawing issues with tablines and such). f_win_splitmove also has some bugs. So check for room and fix the issues in f_win_splitmove. Handle failure in the two relevant win_split_ins callers by restoring the original layout, and factor the common logic into win_splitmove. Don't check for room when opening an autocommand window, as it's a temporary window that's rarely interacted with or drawn anyhow, and is rather important for some autocommands. Issues fixed in f_win_splitmove: - Error if splitting is disallowed. - Fix heap-use-after-frees if autocommands fired from switching to "targetwin" close "wp" or "oldwin". - Fix splitting the wrong window if autocommands fired from switching to "targetwin" switch to a different window. - Ensure -1 is returned for all errors. Also handle allocation failure a bit earlier in make_snapshot (callers, except win_splitmove, don't really care if a snapshot can't be made, so just ignore the return value). Note: Test_smoothscroll_in_zero_width_window failed after these changes with E36, as it was using the previous behaviour to create a zero-width window. I've fixed the test such that it fails with UBSAN as expected when v9.0.1367 is reverted (and simplified it too). related: #14042 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 20 Feb 2024 22:30:04 +0100
parents 29ec2c198c8d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Vim filetype plugin file
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Language: Julia
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 " Homepage: https://github.com/JuliaEditorSupport/julia-vim
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Last Change: 2021 Aug 04
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 " adapted from upstream 2021 Aug 4
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 if exists("b:did_ftplugin")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 finish
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 let b:did_ftplugin = 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let s:save_cpo = &cpo
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 set cpo-=C
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 setlocal include=^\\s*\\%(reload\\\|include\\)\\>
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 setlocal suffixesadd=.jl
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 setlocal comments=:#
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 setlocal commentstring=#\ %s
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 setlocal cinoptions+=#1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 setlocal define=^\\s*macro\\>
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 setlocal fo-=t fo+=croql
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 let b:julia_vim_loaded = 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 let b:undo_ftplugin = "setlocal include< suffixesadd< comments< commentstring<"
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 \ . " define< fo< shiftwidth< expandtab< indentexpr< indentkeys< cinoptions< completefunc<"
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 \ . " | unlet! b:julia_vim_loaded"
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 " MatchIt plugin support
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 if exists("loaded_matchit")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 let b:match_ignorecase = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 " note: begin_keywords must contain all blocks, in order
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 " for nested-structures-skipping to work properly
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 " note: 'mutable struct' and 'struct' are defined separately because
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 " using \? puts the cursor on 'struct' instead of 'mutable' for some reason
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 let b:julia_begin_keywords = '\%(\.\s*\|@\)\@<!\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 " note: the following regex not only recognizes macros, but also local/global keywords.
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 " the purpose is recognizing things like `@inline myfunction()`
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 " or `global myfunction(...)` etc, for matchit and block movement functionality
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 let s:macro_regex = '\%(@\%([#(]\@!\S\)\+\|\<\%(local\|global\)\)\s\+'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let s:nomacro = '\%(' . s:macro_regex . '\)\@<!'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 let s:yesmacro = s:nomacro . '\%('. s:macro_regex . '\)\+'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let b:julia_begin_keywordsm = '\%(' . s:yesmacro . b:julia_begin_keywords . '\)\|'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 \ . '\%(' . s:nomacro . b:julia_begin_keywords . '\)'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 let b:julia_end_keywords = '\<end\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 " note: this function relies heavily on the syntax file
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 function! JuliaGetMatchWords()
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 let [l,c] = [line('.'),col('.')]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 let attr = synIDattr(synID(l, c, 1),"name")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 let c1 = c
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 while attr == 'juliaMacro' || expand('<cword>') =~# '\<\%(global\|local\)\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 normal! W
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 if line('.') > l || col('.') == c1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call cursor(l, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 return ''
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 let attr = synIDattr(synID(l, col('.'), 1),"name")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 let c1 = col('.')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 endwhile
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 call cursor(l, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 if attr == 'juliaConditional'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 return b:julia_begin_keywordsm . ':\<\%(elseif\|else\)\>:' . b:julia_end_keywords
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 elseif attr =~# '\<\%(juliaRepeat\|juliaRepKeyword\)\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 return b:julia_begin_keywordsm . ':\<\%(break\|continue\)\>:' . b:julia_end_keywords
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 elseif attr == 'juliaBlKeyword'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 return b:julia_begin_keywordsm . ':' . b:julia_end_keywords
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 elseif attr == 'juliaException'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 return b:julia_begin_keywordsm . ':\<\%(catch\|finally\)\>:' . b:julia_end_keywords
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 return '\<\>:\<\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 let b:match_words = 'JuliaGetMatchWords()'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 " we need to skip everything within comments, strings and
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 " the 'begin' and 'end' keywords when they are used as a range rather than as
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 " the delimiter of a block
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 let b:match_skip = 'synIDattr(synID(line("."),col("."),0),"name") =~# '
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 \ . '"\\<julia\\%(Comprehension\\%(For\\|If\\)\\|RangeKeyword\\|Comment\\%([LM]\\|Delim\\)\\|\\%([bs]\\|Shell\\|Printf\\|Doc\\)\\?String\\|StringPrefixed\\|DocStringM\\(Raw\\)\\?\\|RegEx\\|SymbolS\\?\\|Dotted\\)\\>"'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 let b:undo_ftplugin = b:undo_ftplugin
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 \ . " | unlet! b:match_words b:match_skip b:match_ignorecase"
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 \ . " | unlet! b:julia_begin_keywords b:julia_end_keywords"
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 \ . " | delfunction JuliaGetMatchWords"
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 let &cpo = s:save_cpo
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 unlet s:save_cpo