Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes calculation of line to unset vertical indent in the event of a mouse down #263

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

dingfeli
Copy link
Contributor

Issue #, if available:
During a suggestion preview, we terminate the preview session on mouse down.
The termination is a multi-step process, one of which is unsetting the vertical indent in the line below invocation line.
This line is dynamic and is relative to where the current caret offset is. This means you cannot simply note down the line number to unset it later. This is because user might insert new line during the typeahead.

Thus far, the call made to unset the vertical indent uses the caret listener to keep track of the last known line. This works well enough until you have key registers that marks a flag that keeps track of why the caret has moved, used in communication between the QInlineInputListener with the caret listener, to "text input" without triggering a caret movement (e.g. modifier keys such as shift, or commands that do not produce an input / insertion). Normally, the caret movement reason is reset by the caret listener. But because the caret never moves under these modifier / command key input, this flag is never reset.

When a mouse down happens, the caret listener is called before the mouse listener. Therefore prematurely updating the caret position to where the mouse down happens. By the time the mouse listener gets called, it gets the incorrect line to pass to the vertical indent unset.

The quick fix here is to make it so that the mouse listener does not rely on caret listener to derive the line number. But a proper fix is needed to simplify the interactions between caret listener and QInputListener.

Description of changes:

  • Calculates line to unset vertical indent based on invocation offset and distance traversed in typeahead.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dingfeli dingfeli requested a review from breedloj November 22, 2024 00:19
@dingfeli dingfeli merged commit 4532524 into main Nov 22, 2024
1 check passed
@dingfeli dingfeli deleted the fix-mouse-down-line-calculation branch November 22, 2024 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants