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

Pre-fill the text under the cursor when pressing F1 in the script editor #4577

Open
ssokolow opened this issue May 22, 2022 · 1 comment
Open

Comments

@ssokolow
Copy link

ssokolow commented May 22, 2022

Describe the project you are working on

A 2D game using GDScript

Describe the problem or limitation you are having in your project

The Lookup Symbol context menu entry lists no hotkey and the most intuitive solution is to select or position my text cursor within the identifier I want to look up and hit F1... which doesn't have the desired result.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

When F1 is pressed, pre-fill the identifer under the text cursor in the Search Help window so the user only needs to press Enter if that's what they wanted and pre-select the filled text so they still don't need to manually erase it otherwise.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

  1. If the cursor is on or at the end of something that is not an identifier, pre-fill the search field with that text and pre-select it so the user doesn't need to manually erase it if that was undesired.
  2. If Lookup Symbol and the Search Help window's as-you-type selection use different algorithms, run a safety check to ensure that it highlighted the entry that Lookup Symbol would have.

This approach has three advantages:

  1. It makes typing vecF1 and F1vec functionally equivalent, minimizing the need for the user to maintain more complex habits and making the system more forgiving of errors.
  2. It achieves keyboard-friendly "put the cursor inside a recognized identifier, press F1, and then press Enter to look it up" behaviour by reusing as much existing behaviour as possible.
  3. It's makes something someone may intuitively try Just Work™

Alternatively, you could add a keybind for Lookup Symbol that doesn't go via the Search Help dialog, though I'd still like to have it pre-fill F1 so I don't have to go "Oops. Ctrl+Shift+Left, Ctrl+C, F1, Ctrl+V" when working off habits from other systems which expect you to type into the document and then trigger something to consume the word you typed, such as Vim leader commands. (eg. UltiSnips)

If this enhancement will not be used often, can it be worked around with a few lines of script?

No. It's an editor ergonomics enhancement.

Is there a reason why this should be core and not an add-on in the asset library?

So it can enhance the existing F1 keybind and Lookup Identifier functionality with a trivial bit of glue rather than reinventing them on a less intuitive keybinding.

@Calinou
Copy link
Member

Calinou commented Dec 16, 2024

This is already available with Contextual Help, which defaults to Alt + F1.

However, this begs the question of whether we should do this by default when pressing F1 (and remove Contextual Help as it'll no longer be needed). The text is already selected, so if you enter anything, it'll be overwritten anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants