We skip most recent history entry (in either direction) if it equals the current autosuggestion because if user cycles when auto-suggestion is shown they most likely want something else than what was suggested (otherwise they would have accepted the suggestion).
(
buffer: Buffer,
provider: NavigableAutoSuggestFromHistory,
direction_method: Callable,
)
| 607 | |
| 608 | |
| 609 | def _swap_autosuggestion( |
| 610 | buffer: Buffer, |
| 611 | provider: NavigableAutoSuggestFromHistory, |
| 612 | direction_method: Callable, |
| 613 | ): |
| 614 | """ |
| 615 | We skip most recent history entry (in either direction) if it equals the |
| 616 | current autosuggestion because if user cycles when auto-suggestion is shown |
| 617 | they most likely want something else than what was suggested (otherwise |
| 618 | they would have accepted the suggestion). |
| 619 | """ |
| 620 | suggestion = buffer.suggestion |
| 621 | if not suggestion: |
| 622 | return |
| 623 | |
| 624 | query = _get_query(buffer.document) |
| 625 | current = query + suggestion.text |
| 626 | |
| 627 | direction_method(query=query, other_than=current, history=buffer.history) |
| 628 | |
| 629 | new_suggestion = provider.get_suggestion(buffer, buffer.document) |
| 630 | buffer.suggestion = new_suggestion |
| 631 | |
| 632 | |
| 633 | def swap_autosuggestion_up(event: KeyPressEvent): |
no test coverage detected
searching dependent graphs…