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

add commands for opening "find references" in bottom or quick panel #2409

Merged
merged 11 commits into from
Feb 3, 2024

Conversation

rchl
Copy link
Member

@rchl rchl commented Jan 28, 2024

Include an additional variant of the Find references command in Command Palette and menus that allows to show references in the way that is opposite to the default behavior (which depends on show_references_in_quick_panel).

So when show_references_in_quick_panel is enabled, we'll show Find References (in bottom panel) in addition to the default Find References and if show_references_in_quick_panel is disabled we'll show Find References (in quick panel) so that both variants are always accessible.

The reason for that is that while showing references in the quick panel is typically the preferred way, one might want to occasionally show those in the bottom panel to be able to keep the list as a reference when wanting to update all results manually.

Copy link

netlify bot commented Jan 28, 2024

Deploy Preview for sublime-lsp ready!

Name Link
🔨 Latest commit 17626d5
🔍 Latest deploy log https://app.netlify.com/sites/sublime-lsp/deploys/65b6d58b6f90960009f8a8ab
😎 Deploy Preview https://deploy-preview-2409--sublime-lsp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 28, 2024

Deploy Preview for sublime-lsp ready!

Name Link
🔨 Latest commit 0eaa563
🔍 Latest deploy log https://app.netlify.com/sites/sublime-lsp/deploys/65bbed4443bd9e00085b90da
😎 Deploy Preview https://deploy-preview-2409--sublime-lsp.netlify.app/keyboard_shortcuts
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jwortmann
Copy link
Member

For the context menu, would it be better to change to the alternative display method if a modifier key is pressed when you select the "Find References" item? I think the additional entry is okay for the command palette, but I think it's not the best UI to have two of the items with basically the same functionality in the context menu. Modifier keys for the context menu should work fine (you can confirm by adding print(event) in run()):

{'modifier_keys': {}, 'x': 654.5, 'y': 518.5, 'text_point': 2176}
{'modifier_keys': {'primary': True, 'ctrl': True}, 'x': 652.5, 'y': 518.5, 'text_point': 2176}

@rchl
Copy link
Member Author

rchl commented Jan 29, 2024

That would make the feature pretty much impossible to discover though...

@jwortmann
Copy link
Member

I gues most users are satisfied with having the global "how_references_in_quick_panel": true/false setting. The only request for that in the issue tracker I can see is from you: #2084
I don't want to say that it isn't a valid request, but we could mention it in a sentence in the docs and if someone searches or asks for it, it shouldn't be too hard to find out about it. There are also no additional context menu items for the other command arguments; for example we have the key binding for side-by-side (using the default keys from ST) even commented out, and we have no explicit context menu item "Find References (side by side)"
https://github.com/sublimelsp/LSP/blob/8023408dfd7917d23f89c9bb3f7356a4d2d1d895/Default.sublime-keymap#L70C1-L76C10

@jwortmann
Copy link
Member

Actually we could even use the modifier key too for the side-by-side mode. This would only be relevant if it is displayed in the quick panel. I.e. activate side-by-side if Shift is pressed (like in the default key binding) and change panel mode (bottom/quick panel) if Primary is pressed.

@rchl
Copy link
Member Author

rchl commented Jan 29, 2024

activate side-by-side if Shift is pressed (like in the default key binding)

Actually, the primary key is used to trigger side-by-side. Which doesn't give us a lot of wiggle room.

That means that ideally for the side-by-side triggered from the context menu we'd also need to use primary (ctrl on win, cmd on mac) but then what would we use for "default-inverted" action? Shift? Doesn't feel quite right.

@rchl
Copy link
Member Author

rchl commented Jan 29, 2024

I've added support for holding primary key while triggering context menu item but haven't added support for triggering "non-default" behavior yet. I guess the only option is to go with shift here?

@jwortmann
Copy link
Member

jwortmann commented Jan 30, 2024

Yes, I confused the Shift and Primary keys above. I think now it is better than adding an additional context menu item.

A few more suggestions for the labels and names:

  • Is there maybe a better name for the "show_in" argument? I'd prefer finding one or two words to describe the argument (usually as a noun) if possible, instead of looking like an incomplete sentence. For example
    • "quick_panel": true/false (this would be bad if another mode should be added in the future though)
    • "display_mode"
    • "presentation"
    • or maybe you have another idea with a better name
  • I would probably use "output_panel" instead of "bottom_panel" for the option and for the command palette label. Because it may not be restricted to the bottom forever, if ST adds more flexibility for the panels in a future release (Allow the Console and Build panel to be moved to the right side, up side, left side, any side sublimehq/sublime_text#1451)
  • I think the word "in" should be removed from the command palette labels, currently it reads a bit as if the command would do the search inside the panel. Or alternatively add "show in"
    • "LSP: Find References (Quick Panel)"
    • "LSP: Find References (Output Panel)"

@rchl
Copy link
Member Author

rchl commented Jan 31, 2024

The reason I've used "bottom panel" is to match the description of the setting:

  // Show symbol references in Sublime's quick panel instead of the bottom panel.
  "show_references_in_quick_panel": true,

but I'm fine with changing both.

@rchl
Copy link
Member Author

rchl commented Jan 31, 2024

  • "quick_panel": true/false

Don't like this since it's not clear what "false" means.
I don't know if I have good suggestions... output or target come to mind

@predragnikolic
Copy link
Member

predragnikolic commented Jan 31, 2024

I tried pressing shift+enter in the context menu, but it does nothing for me.
Only when I press just enter, then it works (end of the gif when the quick panel opens)

output

I did a little search in my keybindings, and found out that I had shift+enter in it, so I commented that out, but it still doesn't work.

    // {
    //     "command": "lsp_commit_completion_with_opposite_insert_mode",
    //     "keys": [
    //         "shift+enter"
    //     ],
    //     "context": [
    //         {
    //             "key": "auto_complete_visible",
    //             "operator": "equal",
    //             "operand": true
    //         },
    //         {
    //             "key": "lsp.session_with_capability",
    //             "operator": "equal",
    //             "operand": "completionProvider"
    //         }
    //     ]
    // },

EDIT: it does work as expected when I invoke it from Goto > LSP: Find References

@rchl
Copy link
Member Author

rchl commented Jan 31, 2024

Does it work to press shift+enter on other menu items? If it doesn't work with those that don't handle shift specifically (so basically most of them) then I would assume it's a Linux/Window Manager thing.

Comment on lines 142 to 144
show_in_quick_panel = show_in == 'quick_panel' or show_in is None and userprefs().show_references_in_quick_panel
if modifier_keys.get('shift'):
show_in_quick_panel = not show_in_quick_panel
Copy link
Member Author

Choose a reason for hiding this comment

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

I've realized that I should only be handling shift when "show_in" is not specified.

@rchl
Copy link
Member Author

rchl commented Jan 31, 2024

  • "quick_panel": true/false

Don't like this since it's not clear what "false" means. I don't know if I have good suggestions... output or target come to mind

show_mode?

@jwortmann
Copy link
Member

show_mode?

Hm... this sounds a bit like a "TV show" or something. I like your "output" suggestion, or "output_mode", or "display_mode".

The command caption still has "Bottom Panel" instead of "Output Panel" currently.

plugin/__init__.py Outdated Show resolved Hide resolved
@rchl rchl merged commit 8696a5d into main Feb 3, 2024
8 checks passed
@rchl rchl deleted the feat/add-find-references-variant branch February 3, 2024 19:15
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