summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-language-server-completion.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-07-14 10:53:39 -0700
committerGitHub <noreply@github.com>2022-07-14 10:53:39 -0700
commit5949e2c5c0c205d5dafeabe88646e96b2a60ec9e (patch)
tree77bf07d8b34ecedea106b177ee92a1ec48f9aa82 /source/slang/slang-language-server-completion.cpp
parent4af61e2296a49876c2d9e7cf192ae825302a83de (diff)
Language Server: Auto format bug fixes. (#2326)
Diffstat (limited to 'source/slang/slang-language-server-completion.cpp')
-rw-r--r--source/slang/slang-language-server-completion.cpp30
1 files changed, 25 insertions, 5 deletions
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<LanguageServerProtocol::TextEditCompletionItem> 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<LanguageServerProtocol::TextEditCompletionItem> items;
@@ -132,7 +142,8 @@ List<LanguageServerProtocol::TextEditCompletionItem> 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<LanguageServerProtocol::TextEditCompletionItem> 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;