From 9819cb9a7e141760b01e041ed45f875e81056064 Mon Sep 17 00:00:00 2001 From: Peter Jankuliak Date: Sun, 28 May 2023 15:49:42 +0100 Subject: [PATCH] Cache full paths in LspFileToUri --- autoload/lsp/util.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index 62d936f..2b157de 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -111,17 +111,21 @@ var resolvedUris = {} # Convert a Vim filename to an LSP URI (file://) export def LspFileToUri(fname: string): string - if resolvedUris->has_key(fname) - return resolvedUris[fname] + var fname_full: string = fname->fnamemodify(':p') + + if resolvedUris->has_key(fname_full) + return resolvedUris[fname_full] endif - var uri: string = fname->fnamemodify(':p') + var uri: string if has("win32unix") # We're in Cygwin, convert POSIX style paths to Windows style. # The substitution is to remove the '^@' escape character from the end of # line. - uri = system($'cygpath -m {uri}')->substitute('^\(\p*\).*$', '\=submatch(1)', "") + uri = system($'cygpath -m {fname_full}')->substitute('^\(\p*\).*$', '\=submatch(1)', "") + else + uri = fname_full endif var on_windows: bool = false @@ -143,7 +147,7 @@ export def LspFileToUri(fname: string): string uri = $'file://{uri}' endif - resolvedUris[fname] = uri + resolvedUris[fname_full] = uri return uri enddef -- 2.48.1