From 0bf899a5f8110fbea97272bdda03b68b91745e51 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 1 Jul 2022 15:09:24 -0700 Subject: Language server: auto completion of `import` file and directories. (#2312) * Language server: auto completion of `import` file and directories. * Completion of include path. * Improvements. Co-authored-by: Yong He --- source/core/slang-string.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source/core/slang-string.cpp') diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index 03de07ee1..c02ba048d 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -134,7 +134,7 @@ namespace Slang if (otherSize > thisSize) return false; - return UnownedStringSlice(begin(), begin() + otherSize) == other; + return head(otherSize) == other; } bool UnownedStringSlice::startsWith(char const* str) const @@ -142,6 +142,17 @@ namespace Slang return startsWith(UnownedTerminatedStringSlice(str)); } + bool UnownedStringSlice::startsWithCaseInsensitive(UnownedStringSlice const& other) const + { + UInt thisSize = getLength(); + UInt otherSize = other.getLength(); + + if (otherSize > thisSize) + return false; + + return head(otherSize).caseInsensitiveEquals(other); + } + bool UnownedStringSlice::endsWith(UnownedStringSlice const& other) const { @@ -474,6 +485,8 @@ namespace Slang { auto oldLength = getLength(); auto textLength = textEnd - textBegin; + if (textLength <= 0) + return; auto newLength = oldLength + textLength; -- cgit v1.2.3