File tree Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Original file line number Diff line number Diff line change @@ -2376,14 +2376,7 @@ var wordSeparators = collections.NewSetFromItems(
2376
2376
// e.g. for "abc def.ghi|jkl", the word length is 3 and the word start is 'g'.
2377
2377
func getWordLengthAndStart (sourceFile * ast.SourceFile , position int ) (wordLength int , wordStart rune ) {
2378
2378
// !!! 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 ]
2387
2380
totalSize := 0
2388
2381
var firstRune rune
2389
2382
for r , size := utf8 .DecodeLastRuneInString (text ); size != 0 ; r , size = utf8 .DecodeLastRuneInString (text [:len (text )- totalSize ]) {
@@ -2492,13 +2485,7 @@ func getFilterText(
2492
2485
2493
2486
// Ported from vscode's `provideCompletionItems`.
2494
2487
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 ]
2502
2489
totalSize := 0
2503
2490
if strings .HasSuffix (text , "?." ) {
2504
2491
totalSize += 2
You can’t perform that action at this time.
0 commit comments