diff --git a/coq/clients/cache/worker.py b/coq/clients/cache/worker.py index 80df6ba1..2179e0c6 100644 --- a/coq/clients/cache/worker.py +++ b/coq/clients/cache/worker.py @@ -37,6 +37,7 @@ class _CacheCtx: row: int col: int syms_before: str + words_before: str def _use_cache(match: MatchOptions, cache: _CacheCtx, ctx: Context) -> bool: @@ -46,6 +47,7 @@ def _use_cache(match: MatchOptions, cache: _CacheCtx, ctx: Context) -> bool: and cache.commit_id == ctx.commit_id and ctx.buf_id == cache.buf_id and row == cache.row + and bool(cache.words_before) == bool(ctx.words_before) and multi_set_ratio( ctx.syms_before, cache.syms_before, look_ahead=match.look_ahead ) @@ -88,6 +90,7 @@ def __init__(self, supervisor: Supervisor) -> None: row=-1, col=-1, syms_before="", + words_before="", ) self._clients: MutableSet[str] = set() self._cached: MutableMapping[bytes, Completion] = {} @@ -137,6 +140,7 @@ def apply_cache( row=row, col=col, syms_before=context.syms_before, + words_before=context.words_before, ) use_cache = _use_cache( @@ -165,7 +169,10 @@ def get() -> Iterator[Completion]: for key, sort_by in selected: if (comp := self._cached.get(key)) and ( cached := sanitize_cached( - inline_shift, cursor=context.cursor, comp=comp, sort_by=sort_by + inline_shift, + cursor=context.cursor, + comp=comp, + sort_by=sort_by, ) ): if (