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

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

Closed
jwbowler opened this issue Apr 30, 2024 · 1 comment · Fixed by #16382

Comments

@jwbowler
Copy link

jwbowler commented Apr 30, 2024

Description :octocat:

If you enter symbol-highlight-transient-state, search backward, and exit the transient state, n and N are now switched vs. their usual Vim-style behavior.

I have zero experience with ELisp, but, some things I observe from poking around layers/+spacemacs/spacemacs-navigation:

  • In funcs.el, spacemacs//ahs-ts-on-exit has a comment about "Restore user search direction state..." - it seems relevant, is this just not working?
  • In packages.el, the above function is set as the :on-exit of spacemacs|define-transient-state symbol-highlight. But, using edebug-defun on that function, it seems to get called each time I hit the n or p key in symbol-highlight-transient-state, which seems weird?

I observe this behavior on my freshly-installed MacOS Spacemacs as well as my Linux Spacemacs in the office.

Reproduction guide 🪲

  • Install a fresh Spacemacs; start Emacs
  • Type in scratch buffer: "foo foo foo foo"
  • Cursor over the first "foo" and hit * to enter symbol-highlight-transient-state
  • Hit p to go to the previous match
  • Hit q to exit the transient state

Observed behaviour: 👀 💔
n now searches backward through "foo"s

Expected behaviour: ❤️ 😄
n now searches forward through "foo"s

System Info 💻

  • OS: darwin
  • Emacs: 29.3
  • Spacemacs: 0.999.0
  • Spacemacs branch: develop (rev. a58a7d7)
  • Graphic display: nil
  • Running in daemon: nil
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(emacs-lisp helm multiple-cursors treemacs)
  • System configuration features: ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE PDUMPER SQLITE3 THREADS TREE_SITTER ZLIB

Backtrace 🐾

N/A

@fnussbaum
Copy link
Contributor

Thanks for the report, I have drafted a PR that would fix this: #16382

In the meantime, something like the following could serve as a workaround:

(defun fix/spacemacs//ahs-ts-on-exit ()
    (setq evil-ex-search-direction (if spacemacs--ahs-searching-forward 'forward 'backward)))
(advice-add 'spacemacs//ahs-ts-on-exit :after 'fix/spacemacs//ahs-ts-on-exit)

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 a pull request may close this issue.

2 participants