Skip to content

Commit 0fead3a

Browse files
committed
Refactor relative path handling for clarity
1 parent 6c2d4b4 commit 0fead3a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

autoload/OmniSharp/util.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,15 @@ function! OmniSharp#util#TranslatePathForClient(filename) abort
285285
if modifiers ==# 'relative'
286286
let filename = fnamemodify(filename, ':p')
287287
let common = escape(getcwd(), '\')
288-
let result = ''
289-
while substitute(filename, common . s:dir_separator, '', '') ==# filename
290-
\ && common !=# fnamemodify(common, ':h')
288+
let relpath = substitute(filename, '^' . common . s:dir_separator, '', '')
289+
let relprefix = ''
290+
while relpath ==# filename && common !=# fnamemodify(common, ':h')
291291
let common = fnamemodify(common, ':h')
292-
let result .= '..' . s:dir_separator
292+
let relpath = substitute(filename, '^' . common . s:dir_separator, '', '')
293+
let relprefix .= '..' . s:dir_separator
293294
endwhile
294295
if common !=# fnamemodify(common, ':h')
295-
return result . substitute(filename, common . s:dir_separator, '', '')
296+
return relprefix . relpath
296297
endif
297298
let modifiers = ':p'
298299
endif

0 commit comments

Comments
 (0)