From: Peter Jankuliak
Date: Sun, 28 May 2023 14:49:42 +0000 (+0100)
Subject: Cache full paths in LspFileToUri
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=9819cb9a7e141760b01e041ed45f875e81056064;p=vim-lsp.git
Cache full paths in LspFileToUri
---
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