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

Fix and refactor symbol-highlight-transient-state #16382

Merged

Conversation

fnussbaum
Copy link
Contributor

@fnussbaum fnussbaum commented May 1, 2024

Fix some issues with the symbol-highlight-transient-state. In particular this PR fixes #16380. It also simplifies the control flow and fixes some formatting and docstrings. The commit messages and comments contain a detailed breakdown of the changes.

Previously the ts was restarted on every invocation of
`spacemacs//quick-ahs-move'. This is not necessary and led to the
:on-exit-function being called every time.

Instead, we now only start the transient state in all of the entry points:
`spacemacs/enter-ahs-forward', `spacemacs/enter-ahs-backward',
`spacemacs/goto-last-searched-ahs-symbol' and `spacemacs/symbol-highlight'.

Note that `spacemacs//ahs-setup' needs to be called before every entry
point. In `spacemacs//quick-ahs-move' we still have to call `ahs-highlight-now'
to prevent blocking.

Finally, the change allows us to simplify
`spacemacs//disable-symbol-highlight-after-ahs-ts-exit'.
It suffices to do the evil search integration once when leaving the transient
state. This also fixes an issue where, when `evil-search-module' was
`evil-search', the search direction could be inconsistent after leaving the
transient state: Starting in the transient state, and pressing 'N q N' would
make the second 'N' move in the opposite direction of the first 'N'.

To be consistent with expectations (and vanilla evil or vim) the search
direction should be determined only by the function invoking the transient
state (for example through the keys '*' or '#'), and not by how one moved inside
it.

Finally we use `thing-at-point' instead of `evil-find-thing' because the latter
searches forward or backward while the transient state only looks at the symbol
at point. Due to the user-error introduced in the last commit it does not
practically matter (point should always already be at a symbol), but it might
still be a good thing to stay consistent.
@fnussbaum fnussbaum force-pushed the symbol-highlight-search-direction branch from 8a85819 to 533b7df Compare May 4, 2024 18:29
@fnussbaum fnussbaum marked this pull request as ready for review May 4, 2024 18:51
@fnussbaum fnussbaum marked this pull request as draft May 5, 2024 10:49
@fnussbaum fnussbaum marked this pull request as ready for review May 5, 2024 11:08
@kassick
Copy link
Contributor

kassick commented May 6, 2024

I've been testing this locally, did not find any regression, issue was fixed

@smile13241324 smile13241324 merged commit ffebed0 into syl20bnr:develop May 15, 2024
7 of 8 checks passed
ViktorHaag pushed a commit to ViktorHaag/spacemacs that referenced this pull request May 16, 2024
* [symbol-highlight-ts] Do not restart the transient state unnecessarily

Previously the ts was restarted on every invocation of
`spacemacs//quick-ahs-move'. This is not necessary and led to the
:on-exit-function being called every time.

Instead, we now only start the transient state in all of the entry points:
`spacemacs/enter-ahs-forward', `spacemacs/enter-ahs-backward',
`spacemacs/goto-last-searched-ahs-symbol' and `spacemacs/symbol-highlight'.

Note that `spacemacs//ahs-setup' needs to be called before every entry
point. In `spacemacs//quick-ahs-move' we still have to call `ahs-highlight-now'
to prevent blocking.

Finally, the change allows us to simplify
`spacemacs//disable-symbol-highlight-after-ahs-ts-exit'.

* [symbol-highlight-ts] Do not enter the ts if no symbol is found at point

Also fix docstrings and formatting.

* [symbol-highlight-ts] Fix and simplify evil search integration

It suffices to do the evil search integration once when leaving the transient
state. This also fixes an issue where, when `evil-search-module' was
`evil-search', the search direction could be inconsistent after leaving the
transient state: Starting in the transient state, and pressing 'N q N' would
make the second 'N' move in the opposite direction of the first 'N'.

To be consistent with expectations (and vanilla evil or vim) the search
direction should be determined only by the function invoking the transient
state (for example through the keys '*' or '#'), and not by how one moved inside
it.

Finally we use `thing-at-point' instead of `evil-find-thing' because the latter
searches forward or backward while the transient state only looks at the symbol
at point. Due to the user-error introduced in the last commit it does not
practically matter (point should always already be at a symbol), but it might
still be a good thing to stay consistent.
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.

n navigation key can search in the wrong direction after exiting symbol-highlight-transient-state
3 participants