From 5949e2c5c0c205d5dafeabe88646e96b2a60ec9e Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 14 Jul 2022 10:53:39 -0700 Subject: Language Server: Auto format bug fixes. (#2326) --- source/slang/slang-language-server-completion.cpp | 30 +++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-language-server-completion.cpp') diff --git a/source/slang/slang-language-server-completion.cpp b/source/slang/slang-language-server-completion.cpp index adb30df6e..93b10b816 100644 --- a/source/slang/slang-language-server-completion.cpp +++ b/source/slang/slang-language-server-completion.cpp @@ -107,6 +107,16 @@ List CompletionContext::gatherFi Index sectionEnd, char closingChar) { + auto realPrefix = prefixPath.getUnownedSlice(); + while (realPrefix.startsWith("..")) + { + realPrefix = realPrefix.tail(2); + if (realPrefix.startsWith("/") || realPrefix.startsWith("\\")) + { + realPrefix = realPrefix.tail(1); + } + } + struct FileEnumerationContext { List items; @@ -132,7 +142,8 @@ List CompletionContext::gatherFi auto addCandidate = [&](const String& path) { context.path = path; - if (path.getUnownedSlice().endsWithCaseInsensitive(prefixPath.getUnownedSlice())) + Path::getCanonical(context.path, context.path); + if (path.getUnownedSlice().endsWithCaseInsensitive(realPrefix)) { OSFileSystem::getExtSingleton()->enumeratePathContents( path.getBuffer(), @@ -253,12 +264,21 @@ List CompletionContext::gatherFi } } - if (commitCharacterBehavior != CommitCharacterBehavior::Disabled && !isIncomplete) + if (!isIncomplete) { - for (auto& item : context.items) + bool useCommitChars = translateModuleName && (commitCharacterBehavior != CommitCharacterBehavior::Disabled); + if (useCommitChars) { - for (auto ch : getCommitChars()) - item.commitCharacters.add(ch); + if (translateModuleName) + { + for (auto& item : context.items) + { + for (auto ch : getCommitChars()) + { + item.commitCharacters.add(ch); + } + } + } } } return context.items; -- cgit v1.2.3