Skip to content

Commit a7e6193

Browse files
committed
Override g:OmniSharp_edit_command for code edits
1 parent a2ebfd5 commit a7e6193

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

autoload/OmniSharp/locations.vim

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

4-
function! OmniSharp#locations#Navigate(location, noautocmds) abort
4+
function! OmniSharp#locations#Navigate(location, silentedit) abort
55
if a:location.filename !=# ''
66
" Update the ' mark, adding this location to the jumplist.
77
normal! m'
88
if fnamemodify(a:location.filename, ':p') !=# expand('%:p')
9-
execute
10-
\ (a:noautocmds ? 'noautocmd' : '')
11-
\ (&modified && !&hidden ? 'split' : get(g:, 'OmniSharp_edit_command', 'edit'))
12-
\ fnameescape(a:location.filename)
9+
let editcommand = get(g:, 'OmniSharp_edit_command', 'edit')
10+
if a:silentedit
11+
let editcommand = 'edit'
12+
endif
13+
if &modified && !&hidden && editcommand ==# 'edit'
14+
let editcommand = 'split'
15+
endif
16+
if a:silentedit
17+
let editcommand = 'noautocmd ' . editcommand
18+
endif
19+
execute editcommand fnameescape(a:location.filename)
1320
endif
1421
if get(a:location, 'lnum', 0) > 0
1522
let col = get(a:location, 'vcol', 0)

python/omnisharp/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
ctx = VimUtilCtx(vim)
1818

1919

20-
def openFile(filename, line=0, column=0, noautocmd=0):
20+
def openFile(filename, line=0, column=0, silentedit=0):
2121
vim.command("let l:loc = {{ 'filename': '{0}', 'lnum': {1}, 'col': {2} }}"
2222
.format(filename, line, column))
23-
vim.command("call OmniSharp#locations#Navigate(l:loc, {0})".format(noautocmd))
23+
vim.command("call OmniSharp#locations#Navigate(l:loc, {0})".format(silentedit))
2424

2525

2626
def setBuffer(text):
@@ -130,7 +130,7 @@ def runCodeAction(mode, action):
130130
vim.command('let l:hidden_bak = &hidden | set hidden')
131131
for changeDefinition in changes:
132132
filename = formatPathForClient(ctx, changeDefinition['FileName'])
133-
openFile(filename, noautocmd=1)
133+
openFile(filename, silentedit=1)
134134
if not setBuffer(changeDefinition.get('Buffer')):
135135
for change in changeDefinition.get('Changes', []):
136136
setBuffer(change.get('NewText'))

0 commit comments

Comments
 (0)