Skip to content

Commit 0958f39

Browse files
committed
Revert "do not shift inline completions"
This reverts commit 73ef728.
1 parent 73ef728 commit 0958f39

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

coq/clients/cache/worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def _overlap(row: int, edit: BaseRangeEdit) -> bool:
6060

6161

6262
def sanitize_cached(
63-
shift: bool, cursor: Cursors, comp: Completion, sort_by: Optional[str]
63+
cursor: Cursors, comp: Completion, sort_by: Optional[str]
6464
) -> Optional[Completion]:
65-
if edit := sanitize(shift, cursor, edit=comp.primary_edit):
65+
if edit := sanitize(cursor, edit=comp.primary_edit):
6666
row, *_ = cursor
6767
cached = replace(
6868
comp,
@@ -126,7 +126,7 @@ def cont() -> Iterator[Tuple[bytes, str]]:
126126
self._cached.update(new_comps)
127127

128128
def apply_cache(
129-
self, context: Context, always: bool, shift: bool
129+
self, context: Context, always: bool
130130
) -> Tuple[bool, AbstractSet[str], Iterator[Completion]]:
131131
cache_ctx = self._cache_ctx
132132
row, col = context.position
@@ -165,7 +165,7 @@ def get() -> Iterator[Completion]:
165165
for key, sort_by in selected:
166166
if (comp := self._cached.get(key)) and (
167167
cached := sanitize_cached(
168-
shift, cursor=context.cursor, comp=comp, sort_by=sort_by
168+
context.cursor, comp=comp, sort_by=sort_by
169169
)
170170
):
171171
if (

coq/clients/inline/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def cont() -> None:
7171
async def _work(self, context: Context) -> AsyncIterator[Completion]:
7272
async with self._work_lock, self._working:
7373
try:
74-
_, _, cached = self._cache.apply_cache(context, always=True, shift=False)
74+
_, _, cached = self._cache.apply_cache(context, always=True)
7575
lsp_stream = (
7676
self._request(context)
7777
if self._options.live_pulling

coq/clients/lsp/worker.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ async def cont() -> None:
143143
await self._with_interrupt(cont())
144144

145145
async def _work(self, context: Context) -> AsyncIterator[Completion]:
146-
shift = True
147146
limit = (
148147
BIGGEST_INT
149148
if context.manual
@@ -153,7 +152,7 @@ async def _work(self, context: Context) -> AsyncIterator[Completion]:
153152
async with self._work_lock, self._working:
154153
try:
155154
use_cache, cached_clients, cached = self._cache.apply_cache(
156-
context, always=False, shift=shift
155+
context, always=False
157156
)
158157
if not use_cache:
159158
self._local_cached.pre.clear()
@@ -182,10 +181,7 @@ async def stream() -> AsyncIterator[Tuple[_Src, LSPcomp]]:
182181
for item in cached_items
183182
if (
184183
cached := sanitize_cached(
185-
shift=shift,
186-
cursor=context.cursor,
187-
comp=item,
188-
sort_by=None,
184+
context.cursor, comp=item, sort_by=None
189185
)
190186
)
191187
)

coq/server/registrants/repeat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def _edit(prev: Edit) -> Optional[Edit]:
14-
sanitized = sanitize(True, cursor=(-1, -1, -1, -1), edit=prev)
14+
sanitized = sanitize((-1, -1, -1, -1), edit=prev)
1515
new_edit = (
1616
ContextualEdit(
1717
new_text=sanitized.new_text, old_prefix="", new_prefix=sanitized.new_text

coq/shared/repeat.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _shift(cursor: Cursors, edit: BaseRangeEdit) -> Tuple[WTF8Pos, WTF8Pos]:
5353
return new_begin, new_end
5454

5555

56-
def sanitize(shift: bool, cursor: Cursors, edit: Edit) -> Optional[Edit]:
56+
def sanitize(cursor: Cursors, edit: Edit) -> Optional[Edit]:
5757
row, *_ = cursor
5858
if isinstance(edit, SnippetRangeEdit):
5959
if row == -1:
@@ -67,11 +67,9 @@ def sanitize(shift: bool, cursor: Cursors, edit: Edit) -> Optional[Edit]:
6767
return SnippetEdit(grammar=edit.grammar, new_text=fallback)
6868
elif not requires_snip(edit.new_text):
6969
return Edit(new_text=edit.new_text)
70-
elif shift:
70+
else:
7171
begin, end = _shift(cursor, edit=edit)
7272
return replace(edit, begin=begin, end=end)
73-
else:
74-
return edit
7573
elif isinstance(edit, RangeEdit):
7674
if fallback := edit.fallback:
7775
return Edit(new_text=fallback)

0 commit comments

Comments
 (0)