Mercurial > vim
annotate runtime/pack/dist/opt/editexisting/plugin/editexisting.vim @ 33090:461541d860ac v9.0.1830
patch 9.0.1830: Vim9: crash when accessing a null object
Commit: https://github.com/vim/vim/commit/d7085a06358c22250a27186bb7d52112ed4addd1
Author: Gianmaria Bajo <mg1979.git@gmail.com>
Date: Thu Aug 31 18:15:26 2023 +0200
patch 9.0.1830: Vim9: crash when accessing a null object
Problem: Vim9: crash when accessing a null object
Solution: Check accessing a NULL object in def function
An object is NULL when the variable is declared, but the constructor
isn't called. Accessing/setting a member on the object crashed Vim.
Note: this happens inside def functions, at script level things work
differently. Accessing a NULL object member results in E1360
(correctly), while setting a value on it results in E1012 (type
mismatch) so there's still something to fix.
closes: #12973
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 31 Aug 2023 18:30:03 +0200 |
parents | 75c283beb74f |
children |
rev | line source |
---|---|
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Vim Plugin: Edit the file with an existing Vim if possible |
32984 | 2 " Maintainer: The Vim Project <https://github.com/vim/vim> |
3 " Last Change: 2023 Aug 13 | |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " To use add ":packadd! editexisting" in your vimrc file. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " This plugin serves two purposes: |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 " 1. On startup, if we were invoked with one file name argument and the file |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 " is not modified then try to find another Vim instance that is editing |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 " this file. If there is one then bring it to the foreground and exit. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 " 2. When a file is edited and a swap file exists for it, try finding that |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 " other Vim and bring it to the foreground. Requires Vim 7, because it |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " uses the SwapExists autocommand event. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 " Function that finds the Vim instance that is editing "filename" and brings |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 " it to the foreground. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 func s:EditElsewhere(filename) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 let fname_esc = substitute(a:filename, "'", "''", "g") |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 let servers = serverlist() |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 while servers != '' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 " Get next server name in "servername"; remove it from "servers". |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 let i = match(servers, "\n") |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 if i == -1 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 let servername = servers |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 let servers = '' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 else |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let servername = strpart(servers, 0, i) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 let servers = strpart(servers, i + 1) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 " Skip ourselves. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 if servername ==? v:servername |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 continue |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " Check if this server is editing our file. |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
38 try |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
39 if remote_expr(servername, "bufloaded('" . fname_esc . "')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
40 " Yes, bring it to the foreground. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
41 if has("win32") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
42 call remote_foreground(servername) |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
43 endif |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
44 call remote_expr(servername, "foreground()") |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
46 if remote_expr(servername, "exists('*EditExisting')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
47 " Make sure the file is visible in a window (not hidden). |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
48 " If v:swapcommand exists and is set, send it to the server. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
49 if exists("v:swapcommand") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
50 let c = substitute(v:swapcommand, "'", "''", "g") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
51 call remote_expr(servername, "EditExisting('" . fname_esc . "', '" . c . "')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
52 else |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
53 call remote_expr(servername, "EditExisting('" . fname_esc . "', '')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
54 endif |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 endif |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
56 |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
57 if !(has('vim_starting') && has('gui_running') && has('gui_win32')) |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
58 " Tell the user what is happening. Not when the GUI is starting |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
59 " though, it would result in a message box. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
60 echomsg "File is being edited by " . servername |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
61 sleep 2 |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
62 endif |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
63 return 'q' |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 endif |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
65 catch /^Vim\%((\a\+)\)\=:E241:/ |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
66 " Unable to send to this server, ignore it. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
67 endtry |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 endwhile |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 return '' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 endfunc |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 " When the plugin is loaded and there is one file name argument: Find another |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 " Vim server that is editing this file right now. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 if argc() == 1 && !&modified |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 if s:EditElsewhere(expand("%:p")) == 'q' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 quit |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 " Setup for handling the situation that an existing swap file is found. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 try |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 au! SwapExists * let v:swapchoice = s:EditElsewhere(expand("<afile>:p")) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 catch |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 " Without SwapExists we don't do anything for ":edit" commands |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 endtry |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 " Function used on the server to make the file visible and possibly execute a |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 " command. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 func! EditExisting(fname, command) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 " Get the window number of the file in the current tab page. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 let winnr = bufwinnr(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 if winnr <= 0 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 " Not found, look in other tab pages. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 let bufnr = bufnr(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 for i in range(tabpagenr('$')) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 if index(tabpagebuflist(i + 1), bufnr) >= 0 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 " Make this tab page the current one and find the window number. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 exe 'tabnext ' . (i + 1) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 let winnr = bufwinnr(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 break |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 endfor |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 if winnr > 0 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 exe winnr . "wincmd w" |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 elseif exists('*fnameescape') |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 exe "split " . fnameescape(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 else |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 exe "split " . escape(a:fname, " \t\n*?[{`$\\%#'\"|!<") |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 if a:command != '' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 exe "normal! " . a:command |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 redraw |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 endfunc |