RandomFractals / vscode-snippets-viewer

Snippets viewer for VSCode
https://marketplace.visualstudio.com/items?itemName=RandomFractalsInc.snippets-viewer
GNU General Public License v3.0
8 stars 1 forks source link

Add fuzzy search to narrow down snippets in tree view #16

Open ecool opened 3 years ago

ecool commented 3 years ago

Allow for the ability to fuzzy search for snippets with the ability to select which language. Could also have the selected language be selected based on active editor language id.

Possible question about what happens when an active editor language embeds other languages into it. ie: HTML which allows for embedding CSS or JavaScript.

RandomFractals commented 3 years ago

@ecool I think #18 and #19 should cover limiting display of all built-in snippets and snippets for certain languages to some extent.

By fuzzy search, do you mean adding Search Snippets Input and display results for matching snippet name or description with regex?

As for language snippets auto-select, I'll just show snippets listed for the active editor document language id in #10. Users should be able to navigate to other language snippets if desired. Some actually list other language snippets already.

ecool commented 3 years ago

@RandomFractals I meant with language id being used in limiting which snippets are shown in the search.

Input box for searching based on regex matching would work and can be narrowed further by selecting a language to search through which could be a dropdown.

However, it could be combined with #10 so only need to type in your search.

RandomFractals commented 3 years ago

well, you can select a language from a tree. I think that should be the same for search results too, unless explicitly selected to skip language in #19.

I'll add Search Snippets input to show all snippets with matching name or description regex. Not sure how useful it will be, but maybe that's one way to see import snippets in all languages :)

This will be lower priority compared to other tickets I created for the basic snippets display toggles I want to add first.

ecool commented 3 years ago

Opening up the specific languages in the tree to search would work like what I was thinking.

RandomFractals commented 3 years ago

I can add Search button to root and language nodes. Then Search invoked on snippet language node would prompt for a regex to match only for snippets under that language. Would that work?

Bigger questions are:

  1. Do we show results in the snippets webview I plan to add in #5?
  2. or display results in snippets tree view and have another button to clear search?
  3. Do we want to save entered search patterns and let users enter new search or pick one of the recently used?

This can get complicated. Still not sure how useful searching snippets for import or component across all snippet files for a language would be.

ecool commented 3 years ago

Hmm, I was thinking of something similar as to how the Command Pallete behaves and just double checking now shows that it already has a way to filter snippets. Insert Snippet allows for filtering and searching of snippets affecting the active editor. This may not be needed.

If it was possible to show a tooltip of the snippet that is currently selected in the Command Pallete that would be great but not sure if that behavior fits into this extension.

RandomFractals commented 3 years ago

ah, yes. I forgot about that Insert Snippets command feature, even though it's listed in vscode docs: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_builtin-snippets

Let's still keep it open since that built-in snippets filter option doesn't show snippet body and full info. So, I still think your idea is good and we just need to decide if we show search results in a tree, or a table view I'll be adding, or both. Then you'll be able to see all the snippet info.

I can make that Search prompt behave similar to Input Snippet that shows matching snippets as you type name or description filter.

ecool commented 3 years ago

Yeah, Insert Snippet would work much better if it had a tooltip popup showing the snippet.