Skip to content

Commit 847db7c

Browse files
committed
revert(ls): drop completions guards to keep PR scoped to autoimports (#1691)
1 parent 78a03a4 commit 847db7c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

internal/ls/completions.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,14 +2376,7 @@ var wordSeparators = collections.NewSetFromItems(
23762376
// e.g. for "abc def.ghi|jkl", the word length is 3 and the word start is 'g'.
23772377
func getWordLengthAndStart(sourceFile *ast.SourceFile, position int) (wordLength int, wordStart rune) {
23782378
// !!! Port other case of vscode's `DEFAULT_WORD_REGEXP` that covers words that start like numbers, e.g. -123.456abcd.
2379-
2380-
// Bounds check to prevent slice bounds out of range panic
2381-
sourceText := sourceFile.Text()
2382-
if position < 0 || position > len(sourceText) {
2383-
return 0, 0
2384-
}
2385-
2386-
text := sourceText[:position]
2379+
text := sourceFile.Text()[:position]
23872380
totalSize := 0
23882381
var firstRune rune
23892382
for r, size := utf8.DecodeLastRuneInString(text); size != 0; r, size = utf8.DecodeLastRuneInString(text[:len(text)-totalSize]) {
@@ -2492,13 +2485,7 @@ func getFilterText(
24922485

24932486
// Ported from vscode's `provideCompletionItems`.
24942487
func getDotAccessor(file *ast.SourceFile, position int) string {
2495-
// Bounds check to prevent slice bounds out of range panic
2496-
fileText := file.Text()
2497-
if position < 0 || position > len(fileText) {
2498-
return ""
2499-
}
2500-
2501-
text := fileText[:position]
2488+
text := file.Text()[:position]
25022489
totalSize := 0
25032490
if strings.HasSuffix(text, "?.") {
25042491
totalSize += 2

0 commit comments

Comments
 (0)