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

feat: Add local search in buffer #13053

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oxcrow
Copy link
Contributor

@oxcrow oxcrow commented Mar 8, 2025

Hi everyone,

I added a feature to do local search in the currently opened document buffer to improve user experience.

This feature is similar to global_search but is only limited to one document.

The command is activated by space+l and seems to work well.

Kindly review and allow this feature to be merged.

Thank you
~oxcrow

Screenshot From 2025-03-08 12-31-58

Reasoning

  • The global_search method is quite nice since it works in a fuzzy finding method and provides a table of matches that we can easily preview to find what we want.
  • A similar feature is needed for searching through the currently opened buffer (i.e only one document). We could use global_search however it produces too many false positive results from other files, which makes it difficult to use.
  • The standard local search method using / does not feel very good to use.
  • Other editors such as Emacs/Neovim provide plugins for local search such as Swiper, which feel better to use https://github.com/abo-abo/swiper
  • This feature is implemented to provide a similar feature as Swiper.

Implementation

  • I took the code of global_search and modified it little bit.
  • Specifically I modified the code to only search through the current document.
  • The code works but it should be improved by someone more experienced (if necessary).

Grep search through a local buffer similar to `global_search`.

The method works but it should be improved by someone more experienced.
@nik-rev
Copy link
Contributor

nik-rev commented Mar 8, 2025

Showing the path to the file in the global search picker where there can be lots of files makes sense. But here it doesn't really make sense, because you're searching in the same file - so all picker items will show the same path

Maybe instead of showing the path, show the line number and the string contents of that line in the 2nd column

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