annotate runtime/indent/teraterm.vim @ 33947:f4d88db48a63 v9.0.2168

patch 9.0.2168: Moving tabpages on :drop may cause an endless loop Commit: https://github.com/vim/vim/commit/df12e39b8b9dd39056e22b452276622cb7b617fd Author: Christian Brabandt <cb@256bit.org> Date: Sat Dec 16 13:55:32 2023 +0100 patch 9.0.2168: Moving tabpages on :drop may cause an endless loop Problem: Moving tabpages on :drop may cause an endless loop Solution: Disallow moving tabpages on :drop when cleaning up the arglist first Moving tabpages during drop command may cause an endless loop When executing a :tab drop command, Vim will close all windows not in the argument list. This triggers various autocommands. If a user has created an 'au Tabenter * :tabmove -' autocommand, this can cause Vim to end up in an endless loop, when trying to iterate over all tabs (which would trigger the tabmove autocommand, which will change the tpnext pointer, etc). So instead of blocking all autocommands before we actually try to edit the given file, lets simply disallow to move tabpages around. Otherwise, we may change the expected number of events triggered during a :drop command, which users may rely on (there is actually a test, that expects various TabLeave/TabEnter autocommands) and would therefore be a backwards incompatible change. Don't make this an error, as this could trigger several times during the drop command, but silently ignore the :tabmove command in this case (and it should in fact finally trigger successfully when loading the given file in a new tab). So let's just be quiet here instead. fixes: #13676 closes: #13686 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Dec 2023 14:00:05 +0100
parents ebedba7a4898
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Tera Term Language (TTL)
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
3 " Based on Tera Term Version 4.100
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 " Maintainer: Ken Takata
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5 " URL: https://github.com/k-takata/vim-teraterm
26050
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
6 " Last Change: 2021-10-18
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 " Filenames: *.ttl
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 " License: VIM License
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 if exists("b:did_indent")
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 finish
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 let b:did_indent = 1
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 setlocal nosmartindent
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 setlocal noautoindent
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 setlocal indentexpr=GetTeraTermIndent(v:lnum)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 setlocal indentkeys=!^F,o,O,e
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 setlocal indentkeys+==elseif,=endif,=loop,=next,=enduntil,=endwhile
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20
26050
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
21 let b:undo_indent = "setl ai< inde< indk< si<"
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
22
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 if exists("*GetTeraTermIndent")
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 finish
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 function! GetTeraTermIndent(lnum)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 let l:prevlnum = prevnonblank(a:lnum-1)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 if l:prevlnum == 0
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 " top of file
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 return 0
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 " grab the previous and current line, stripping comments.
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 let l:prevl = substitute(getline(l:prevlnum), ';.*$', '', '')
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 let l:thisl = substitute(getline(a:lnum), ';.*$', '', '')
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 let l:previ = indent(l:prevlnum)
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 let l:ind = l:previ
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40
9908
2b6654519a7c commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents: 6951
diff changeset
41 if l:prevl =~ '^\s*if\>.*\<then\>'
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 " previous line opened a block
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
43 let l:ind += shiftwidth()
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 if l:prevl =~ '^\s*\%(elseif\|else\|do\|until\|while\|for\)\>'
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 " previous line opened a block
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
47 let l:ind += shiftwidth()
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 if l:thisl =~ '^\s*\%(elseif\|else\|endif\|enduntil\|endwhile\|loop\|next\)\>'
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 " this line closed a block
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
51 let l:ind -= shiftwidth()
6951
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 endif
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 return l:ind
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 endfunction
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56
b2673982c625 Updated and new runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 " vim: ts=8 sw=2 sts=2