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): Adding new quick-select dialog #2552

Merged
merged 4 commits into from
Aug 10, 2024

Conversation

ericguin
Copy link
Contributor

This adds a new quick-select dialog much akin to the Command Palette, except instead of selecting commands, it fuzzy finds on node name/path.

This somewhat improves the UX, in my opinion, for quickly switching nodes. There is the Ctrl+T shortcut for "Find in Multiple Nodes...", but that search box does not have suggestions or live filtering.

The inspiration for this feature comes from the Ctrl+P default binding in VS Code where you can search for a file very quickly and switch to it. I have put a default binding of Ctrl+Alt+P in, but that is a very rough "what I could find that wasn't already used" kind of map and I am very open to changing it.

Also note, if there is some reason this feature hasn't been in CherryTree I am happy to abandon the PR. I just think it might make a really cool addition.

This adds a new quick-select dialog much akin to the Command Palette,
except instead of selecting commands, it fuzzy finds on node name/path.

This somewhat improves the UX, in my opinion, for quickly switching
nodes. There is the `Ctrl+T` shortcut for "Find in Multiple Nodes...",
but that search box does not have suggestions or live filtering.

The inspiration for this feature comes from the `Ctrl+P` default binding
in VS Code where you can search for a file very quickly and switch to
it. I have put a default binding of `Ctrl+Alt+P` in, but that is a very
rough "what I could find that wasn't already used" kind of map and I am
very open to changing it.

Also note, if there is some reason this feature hasn't been in
CherryTree I am happy to abandon the PR. I just think it might make a
really cool addition.
{
auto ctit = treeStore.to_ct_tree_iter(iter);
auto full_path = CtMiscUtil::get_node_hierarchical_name(ctit, " / ", false);
spdlog::debug("Node path for {} in ints is: {}", ctit.get_node_name(), path.to_string());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left in my debug on accident

Copy link
Owner

@giuspen giuspen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing your work, please see my review comments

void CtActions::command_selnode()
{
auto id = CtDialogs::dialog_selnode(_pCtMainWin);
auto node_iter = _pCtMainWin->get_tree_store().get_node_from_node_id(id);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you can return an invalid id (-1) for example if the user presses cancel on the dialog, you have to check that the returned node_iter is valid if (node_iter ) or set_cursor_safe() with a bad input will crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh... Completely slipped my mind on that one. Even added the -1 for this very purpose

@@ -0,0 +1,241 @@
/*
* ct_dialogs_cmd_palette.cc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file name to fix after copy/paste

src/ct/ct_menu_actions.cc Show resolved Hide resolved
@ericguin
Copy link
Contributor Author

Thank you for the prompt review! Really loving this software, there's something about it that is finally making it not just easy but fun to finally start organizing my life. Much appreciated.

@giuspen giuspen merged commit 1177510 into giuspen:master Aug 10, 2024
@giuspen
Copy link
Owner

giuspen commented Aug 10, 2024

very nice work @ericguin thanks again for sharing it, I will look for a suitable default keyboard shortcut

@ericguin ericguin deleted the feat/add_quick_switch_dialog branch August 11, 2024 02:17
@metal450
Copy link
Contributor

metal450 commented Oct 6, 2024

This is amazing. A few notes/feedback:

  • Could we have this respect the search exclusions? Ideally with an "Override exclusions" toggle, similar to the main search dialog. In my case, i.e. 75%+ of nodes are in an excluded "Done" folder - but from this search dialog, they're all included,
  • The dialog pops up off-center on the right side of the screen, and then as it populates, becomes even wider, eventually clipping off the right of the screen. This requires manually moving it to the left each time, if you want to see the full names in the results. It would be good to recenter as it populates & resizes.
  • It would be great if the search results could be ordered by most-recently accessed node. That way, one can avoid scrolling down through old nodes that potentially haven't been accessed for awhile, & more commonly-viewed content will naturally find its way to the top. This is how i.e. OneNote works, too. Suggested it awhile ago for the main search, but would be even better here: Search Results Ordered By Recently-Accessed #1831

Thanks again for the awesome feature!

@metal450 metal450 mentioned this pull request Oct 6, 2024
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.

3 participants