annotate runtime/ftplugin.vim @ 34194:a522c6c0127b v9.1.0047

patch 9.1.0047: issues with temp curwin/buf while cmdwin is open Commit: https://github.com/vim/vim/commit/988f74311c26ea9917e84fbae608de226dba7e5f Author: Sean Dewar <seandewar@users.noreply.github.com> Date: Wed Aug 16 14:17:36 2023 +0100 patch 9.1.0047: issues with temp curwin/buf while cmdwin is open Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Alternatively, we could ban win_execute in the cmdwin and audit all places that temporarily change/restore curwin/buf, but I didn't notice any problems arising from allowing this (standard cmdwin restrictions still apply, so things that may actually break the cmdwin are still forbidden). closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 23 Jan 2024 23:00:04 +0100
parents 4027cefc2aab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
1 vim9script noclear
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
3 # Vim support file to switch on loading plugins for file types
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
4 #
32770
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 27634
diff changeset
5 # Maintainer: The Vim Project <https://github.com/vim/vim>
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 27634
diff changeset
6 # Last change: 2023 Aug 10
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 27634
diff changeset
7 # Former Maintainer: Bram Moolenaar <Bram@vim.org>
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
8
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
9 if exists("g:did_load_ftplugin")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
12 g:did_load_ftplugin = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 augroup filetypeplugin
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
15 au FileType * call LoadFTPlugin()
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
16 augroup END
856
8cd729851562 updated for version 7.0g
vimboss
parents: 782
diff changeset
17
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
18 if exists('*LoadFTPlugin')
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
19 # No need to define the function again.
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
20 finish
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
21 endif
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
22
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
23 def LoadFTPlugin()
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
24 if exists("b:undo_ftplugin")
27634
9fe2fed9bb4b Update runtime files. (closes #9741)
Bram Moolenaar <Bram@vim.org>
parents: 27623
diff changeset
25 # We assume b:undo_ftplugin is using legacy script syntax
9fe2fed9bb4b Update runtime files. (closes #9741)
Bram Moolenaar <Bram@vim.org>
parents: 27623
diff changeset
26 legacy exe b:undo_ftplugin
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
27 unlet! b:undo_ftplugin b:did_ftplugin
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
28 endif
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
29
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
30 var s = expand("<amatch>")
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
31 if s != ""
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
32 if &cpo =~# "S" && exists("b:did_ftplugin")
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
33 # In compatible mode options are reset to the global values, need to
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
34 # set the local values also when a plugin was already used.
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
35 unlet b:did_ftplugin
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 36
diff changeset
36 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 782
diff changeset
37
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
38 # When there is a dot it is used to separate filetype names. Thus for
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
39 # "aaa.bbb" load "aaa" and then "bbb".
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
40 for name in split(s, '\.')
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
41 exe 'runtime! ftplugin/' .. name .. '.vim ftplugin/' .. name .. '_*.vim ftplugin/' .. name .. '/*.vim'
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
42 endfor
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
43 endif
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
44 enddef