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 dismiss command for the completer #13771

Closed
wants to merge 29 commits into from

Conversation

TigreModerata
Copy link

References

Issue #13659

Code changes

Added dismiss-widget command to the completer package that gets invoked by Escape in file-editor.
Before, Escape went to document-search:end without there being a search view opened, so the command was not enabled. Now the dismiss command is enabled with the completer.
Dismiss-widget uses dispose() from the completer widget.

User-facing changes

console warning gone.

Backwards-incompatible changes

@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@welcome
Copy link

welcome bot commented Jan 14, 2023

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Thank you for working on this! I left two suggestions.

packages/completer/src/manager.ts Outdated Show resolved Hide resolved
packages/fileeditor-extension/src/commands.ts Outdated Show resolved Hide resolved
TigreModerata and others added 7 commits January 15, 2023 15:25
typo

Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
…ole; added ovverideEsc to fileeditor (to avoid documentsearch:end on Esc).
# Conflicts:
#	packages/completer/src/manager.ts
#	packages/fileeditor-extension/schema/completer.json
#	packages/fileeditor-extension/src/commands.ts
@TigreModerata
Copy link
Author

TigreModerata commented Jan 16, 2023

I added the controller:dismiss-* for all 3 cases, notebook, console and text editor. For the first two I left the selector very specific, jp-mod-completer-active, because I did not want it to pass by the completer if no completer is yet invoked (say you press esc on the console line, I want it to just do what it did before, default of console, not go involve the completer commands). For the case of the fileeditor, the default was the problem (going to documentsearch:end) so I created a new Esc binding which does nothing, leaving the completer:dismiss-file to touch only active completer widgets.
At this point the case 27 (Esc) from the keystroke handler can probably be removed, it does not seem needed anymore, but I wanted to double check with you.

Comment on lines +880 to +888
/**
* Override Esc that causes documentsearch:end, doing nothing
*/
commands.addCommand(CommandIDs.overrideEsc, {
execute: () => {
return;
},
label: trans.__('Override Esc')
});
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding this command we probably should modify how documentsearch:end behaves, e.g. by modifying selector.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure we want to change the documentsearch:end... Its selector is jp-mod-searchable, which includes the container of the whole file editor content page (as it should be, I think).
That is, if I remove the overrideEsc, then pressing esc anywhere else on the sheet (when neither completer or search widget is opened) will go back to the documentsearch:end warning. The warning comes up because indeed no search widget is enabled. One could get rid of the warning :D
I can remove the completer-active part of the selector, that way Esc will always pass through the completer:dismiss-file, even when no completer has been invoked (but maintain the end command if a search widget is opened).
Override Esc or always use completer (or the Escape binding from some other package), I can't come up with a third option...

@TigreModerata
Copy link
Author

I tried changing the selector of documentsearch:end to .jp-DocumentSearch-input, but then my search widget was broken in dev-mode: if any letter typed into search is found in the text, focus changes to the match in the text and one can only overwrite the found result. Cannot get the focus back into the find-view after that and even after closing the widget, matches stay highlighted and focus can't be moved.
I tried rolling back to my previous version, but I had the same behaviour - I think I just hadn't properly tested the searcher before (because I was too focused on the completer)... this makes me suspect it's not the new selector on the documentsearch extension, but I don't see anything else I could have changed.
If anyone has an idea of what I might be messing up, any info is greatly appreciated!

@krassowski
Copy link
Member

If anyone has an idea of what I might be messing up, any info is greatly appreciated!

Was that in the file editor? There are two bugs in the latest version:

which are mostly affecting the file editor. You can safely ignore the file editor for now.

…tSearch-input; removed all completer:dismiss-* from notebook, console and fileeditor as no longer necessary.
@TigreModerata
Copy link
Author

TigreModerata commented Jan 25, 2023

I have nothing to add. Every time i update the branch, it generates new errors, different from the previous ones. I don't know how to fix them.
My last proposal was the "cleanest" i have (meaning it needs the least touching of any other sections). Meaning my last push, where I added the key-binding of Escape, for the documentsearch extension, into the labShellWidgetListener, at the same time the "serachable" class is added to the file-editor widget. This way, if the search is not active, there is no search-specific bind to Esc. When the search field is open, then Esc triggers documentsearch-end, otherwise the default Esc-binding of the current widget will apply. Therefore, all previous changes have been removed as no longer necessary.

@fcollonval fcollonval changed the title Bug#13659 Add dismiss command for the completer Jan 27, 2023
@TigreModerata
Copy link
Author

I'm sure you all have seen this, but in my last push the dismiss command for the completer had been removed. The default key binding to Escape, that was already in the completer, is used. I'm just mentioning it because of the branch name change which makes sense if you use one of the previous commits - consider these had some not so nice workarounds as mentioned in previous comments.

Comment on lines +67 to +73
// Only bind Esc in case the document is currently searchable,
// else it will clash with Esc to close completer on fileeditor
app.commands.addKeyBinding({
command: CommandIDs.end,
keys: ['Escape'],
selector: '.jp-mod-searchable'
});
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe it is doing what you think it does. Once the command is added it will remain there forever. Hence this will only "solve" the problem for the very dismissals of completer which happen before first opening of search panel. Otherwise, it is the same as defining it in schema, but prevents user customisation, so we should not do it.

Copy link
Author

Choose a reason for hiding this comment

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

I guess one could remove the command each time the search widget is closed, each time the texteditor widget loses the "searchable" class... But I guess it's not coherent with the overall style.
I'm guessing you can use or not use whatever commit of mine that you find useful, right, or do you want me to do a rollback to the version with the dismiss command for the completer?

@jtpio jtpio modified the milestones: 4.0.0, 4.0.x May 15, 2023
@krassowski
Copy link
Member

Thank you for opening PR and perseverance! The issue it was trying to solve was closed because another PR addressed the problem using a different approach (#13659 (comment)) and a number of changes on key binding handling were since made.

I need to admit that there was an error of judgement on my side when I labelled the original issue as "good first issue" - it clearly was a difficult one - apologies.

Since the relevant issue was resolved and this PR has conflicts/is not ready I will close it for now , but please feel welcome to open another PR if you would like to contribute in the future!

@krassowski krassowski closed this Jan 22, 2024
@TigreModerata
Copy link
Author

Thanks for the message, I had completely forgotten about this (apologies), as I had probably just given up. Doesn't mean it wasn't a good first issue, just that I had not understood it. Thanks for all your feedback!

@TigreModerata TigreModerata deleted the bug#13659 branch January 23, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants