comparison runtime/pack/dist/opt/editexisting/plugin/editexisting.vim @ 29198:2e6c9df8bea1 v8.2.5118

patch 8.2.5118: MS-Windows: sending a message to another Vim may hang Commit: https://github.com/vim/vim/commit/f9f2a330b961fe1623d428b61afdc52f0af0a666 Author: K.Takata <kentkt@csc.jp> Date: Fri Jun 17 20:05:40 2022 +0100 patch 8.2.5118: MS-Windows: sending a message to another Vim may hang Problem: MS-Windows: sending a message to another Vim may hang if that Vim is halted. Solution: Add a timeout to serverSendToVim(). (Ken Takata, closes #10585)
author Bram Moolenaar <Bram@vim.org>
date Fri, 17 Jun 2022 21:15:03 +0200
parents 57cafbda13ad
children 71cbad0921c9
comparison
equal deleted inserted replaced
29197:d2d4cfebc668 29198:2e6c9df8bea1
1 " Vim Plugin: Edit the file with an existing Vim if possible 1 " Vim Plugin: Edit the file with an existing Vim if possible
2 " Maintainer: Bram Moolenaar 2 " Maintainer: Bram Moolenaar
3 " Last Change: 2016 Mar 28 3 " Last Change: 2022 Jun 17
4 4
5 " To use add ":packadd! editexisting" in your vimrc file. 5 " To use add ":packadd! editexisting" in your vimrc file.
6 6
7 " This plugin serves two purposes: 7 " This plugin serves two purposes:
8 " 1. On startup, if we were invoked with one file name argument and the file 8 " 1. On startup, if we were invoked with one file name argument and the file
33 if servername ==? v:servername 33 if servername ==? v:servername
34 continue 34 continue
35 endif 35 endif
36 36
37 " Check if this server is editing our file. 37 " Check if this server is editing our file.
38 if remote_expr(servername, "bufloaded('" . fname_esc . "')") 38 try
39 " Yes, bring it to the foreground. 39 if remote_expr(servername, "bufloaded('" . fname_esc . "')")
40 if has("win32") 40 " Yes, bring it to the foreground.
41 call remote_foreground(servername) 41 if has("win32")
42 call remote_foreground(servername)
43 endif
44 call remote_expr(servername, "foreground()")
45
46 if remote_expr(servername, "exists('*EditExisting')")
47 " Make sure the file is visible in a window (not hidden).
48 " If v:swapcommand exists and is set, send it to the server.
49 if exists("v:swapcommand")
50 let c = substitute(v:swapcommand, "'", "''", "g")
51 call remote_expr(servername, "EditExisting('" . fname_esc . "', '" . c . "')")
52 else
53 call remote_expr(servername, "EditExisting('" . fname_esc . "', '')")
54 endif
55 endif
56
57 if !(has('vim_starting') && has('gui_running') && has('gui_win32'))
58 " Tell the user what is happening. Not when the GUI is starting
59 " though, it would result in a message box.
60 echomsg "File is being edited by " . servername
61 sleep 2
62 endif
63 return 'q'
42 endif 64 endif
43 call remote_expr(servername, "foreground()") 65 catch /^Vim\%((\a\+)\)\=:E241:/
44 66 " Unable to send to this server, ignore it.
45 if remote_expr(servername, "exists('*EditExisting')") 67 endtry
46 " Make sure the file is visible in a window (not hidden).
47 " If v:swapcommand exists and is set, send it to the server.
48 if exists("v:swapcommand")
49 let c = substitute(v:swapcommand, "'", "''", "g")
50 call remote_expr(servername, "EditExisting('" . fname_esc . "', '" . c . "')")
51 else
52 call remote_expr(servername, "EditExisting('" . fname_esc . "', '')")
53 endif
54 endif
55
56 if !(has('vim_starting') && has('gui_running') && has('gui_win32'))
57 " Tell the user what is happening. Not when the GUI is starting
58 " though, it would result in a message box.
59 echomsg "File is being edited by " . servername
60 sleep 2
61 endif
62 return 'q'
63 endif
64 endwhile 68 endwhile
65 return '' 69 return ''
66 endfunc 70 endfunc
67 71
68 " When the plugin is loaded and there is one file name argument: Find another 72 " When the plugin is loaded and there is one file name argument: Find another