@@ -254,13 +254,21 @@ export class Ddc {
254254 : ( completeStr . length < o . minAutoCompleteLength ||
255255 completeStr . length > o . maxAutoCompleteLength ) ;
256256
257- // Check cache timeout.
258- const currentTime = Math . floor ( Date . now ( ) / 1000 ) ;
259- if (
260- o . cacheTimeout > 0 && this . #prevResults[ s . name ] &&
261- currentTime > this . #prevResults[ s . name ] . time + o . cacheTimeout
262- ) {
263- delete this . #prevResults[ s . name ] ;
257+ if ( s . name in this . #prevResults) {
258+ const currentTime = Math . floor ( Date . now ( ) / 1000 ) ;
259+
260+ // Check cache timeout.
261+ const checkTimeout = o . cacheTimeout > 0 && this . #prevResults[ s . name ] &&
262+ currentTime > this . #prevResults[ s . name ] . time + o . cacheTimeout ;
263+
264+ // Check complete position.
265+ const checkCompletePos =
266+ context . lineNr !== this . #prevResults[ s . name ] . lineNr ||
267+ completePos !== this . #prevResults[ s . name ] . completePos ;
268+
269+ if ( checkTimeout || checkCompletePos ) {
270+ delete this . #prevResults[ s . name ] ;
271+ }
264272 }
265273
266274 // Check previous result.
@@ -269,8 +277,7 @@ export class Ddc {
269277 : null ;
270278
271279 const triggerForIncomplete = ( checkPrevResult ?. isIncomplete ?? false ) &&
272- context . lineNr === checkPrevResult ?. lineNr &&
273- completePos === checkPrevResult ?. completePos && ! invalidCompleteLength ;
280+ ! invalidCompleteLength ;
274281
275282 if (
276283 completePos < 0 ||
@@ -291,12 +298,12 @@ export class Ddc {
291298 new RegExp ( "(?:" + o . volatilePattern + ")$" ) ,
292299 ) !== - 1 ) ;
293300
294- if (
295- ! checkPrevResult ||
301+ const shouldGather = ! checkPrevResult ||
296302 triggerForIncomplete ||
297303 context . event === "Manual" ||
298- ( isVolatile && context . event !== "Update" )
299- ) {
304+ ( isVolatile && context . event !== "Update" ) ;
305+
306+ if ( shouldGather ) {
300307 // Not matched.
301308 const replacePattern = new RegExp ( o . replaceSourceInputPattern ) ;
302309
0 commit comments