@@ -205,6 +205,7 @@ export class AutoCompleteTree {
205
205
column : lines [ lines . length - 1 ] . length + 1 ,
206
206
} ) ;
207
207
}
208
+
208
209
let result : WordCompletion [ ] = [ ] ;
209
210
if ( tokens . length == 0 ) {
210
211
for ( const r of this . roots ) {
@@ -220,13 +221,16 @@ export class AutoCompleteTree {
220
221
nodes : AutoCompleteNode [ ] ,
221
222
tokens : Token [ ] ,
222
223
index : number ,
224
+ cameFromFinal = false ,
223
225
skipStartCheck = false ,
224
226
) : WordCompletion [ ] {
225
227
// check for new start
226
228
if ( ! skipStartCheck && tokens [ index ] . column == 1 ) {
227
229
const matchesAnyRoot = this . roots . some ( ( n ) => n . word . verifyWord ( tokens [ index ] . text ) . length === 0 ) ;
228
230
if ( matchesAnyRoot ) {
229
- return this . completeNode ( this . roots , tokens , index , true ) ;
231
+ return this . completeNode ( this . roots , tokens , index , cameFromFinal , true ) ;
232
+ } else if ( cameFromFinal || nodes . length == 0 ) {
233
+ return this . completeNode ( [ ...this . roots , ...nodes ] , tokens , index , cameFromFinal , true ) ;
230
234
}
231
235
}
232
236
@@ -241,7 +245,7 @@ export class AutoCompleteTree {
241
245
if ( n . word . verifyWord ( tokens [ index ] . text ) . length > 0 ) {
242
246
continue ;
243
247
}
244
- result = result . concat ( this . completeNode ( n . children , tokens , index + 1 ) ) ;
248
+ result = result . concat ( this . completeNode ( n . children , tokens , index + 1 , n . canBeFinal || false ) ) ;
245
249
}
246
250
return result ;
247
251
}
0 commit comments