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

[CLOSED] Explicitly handle Tab keys entered in Quick Open. #4341

Open
core-ai-bot opened this issue Aug 29, 2021 · 11 comments
Open

[CLOSED] Explicitly handle Tab keys entered in Quick Open. #4341

core-ai-bot opened this issue Aug 29, 2021 · 11 comments

Comments

@core-ai-bot
Copy link
Member

Issue by RaymondLim
Wednesday Aug 07, 2013 at 23:20 GMT
Originally opened as adobe/brackets#4697


This fixes issue #4572.


RaymondLim included the following code: https://github.com/adobe/brackets/pull/4697/commits

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Wednesday Aug 07, 2013 at 23:33 GMT


@RaymondLim Can you provide some more detail on what was going wrong, and how this prevents it? It seems impossible for CodeMirror to process the Tab key event itself, and even if it did that doesn't explain how the cursor gets out of sync from the text insertion point. So I'm left feeling worried that there's still a serious CodeMirror bug underneath this, and we're just hiding (one case of) it...

@core-ai-bot
Copy link
Member Author

Comment by RaymondLim
Wednesday Aug 07, 2013 at 23:48 GMT


Tab key entered in Quick Open moves focus out of search text field, which in turn triggers Quick open to close. I'm not sure where the focus goes, but it seems like the editor gets the focus and Tab key event is sent to CodeMirror and it in turn moves the cursor to the end of the current highlighted text. So we're explicitly swallowing the Tab key events here to prevent that.

@core-ai-bot
Copy link
Member Author

Comment by TomMalbran
Thursday Aug 08, 2013 at 00:37 GMT


I just tested adding EditorManager.focusEditor() into the QuickNavigateDialog.prototype._close function, and it now works like tabbing out of the Find in Files dialog.

I can reproduce the same error with both Find and Replace dialogs. But still trying to figure what is wrong with those.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Thursday Aug 08, 2013 at 00:57 GMT


@TomMalbran Interesting find! So, I can repo with those other dialogs only if they create a selection -- if I type nothing before Tab, or if I type something that isn't found, no repro. The behavior across all of these is that the selection is cleared (which normally it would not be), the cursor is placed at the end of the (former) selection, but the text input goes to the beginning of the former selection.

@RaymondLim I think some careful monitoring of the CodeMirror selection code would give us a better idea of what's happening here. Who is clearing the selection? And how are they doing it? Does all of CM know about the selection getting cleared, or are parts of CM's state unaware of that change?

@core-ai-bot
Copy link
Member Author

Comment by TomMalbran
Thursday Aug 08, 2013 at 01:08 GMT


@peterflynn Yes, I can reproduce this errors selecting something and then opening the modal dialogs. Find in Files seems to be the only one that works properly. I also noticed that after tabbing the file gets dirty. So it looks like CodeMirror did something, but failed to replace the text or something.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Thursday Aug 08, 2013 at 01:12 GMT


Also an interesting observation. It looks like a no-op change replacing the selection with the same text as itself. That explains the selection loss and cursor movement (though not the borked CM state). I wonder if CM gets confused by seeing the Tab keyup (which is the only part it would get) and treats the unchanged hidden textarea as if it had been changed... in such a way that its notion of cursor location gets broken.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Thursday Aug 08, 2013 at 01:13 GMT


Aha! I can repro this in vanilla CodeMirror now. Will file a CM bug and set this to tracking.

@core-ai-bot
Copy link
Member Author

Comment by RaymondLim
Thursday Aug 08, 2013 at 01:18 GMT


Thanks@peterflynn and@TomMalbran. Closing this since we need to get a fix from CodeMirror.

@core-ai-bot
Copy link
Member Author

Comment by TomMalbran
Thursday Aug 08, 2013 at 01:23 GMT


Yes, is something like a no-op change, and it doesn't even call the mapped Tab function.

Nice find, as a repro in vanilla CodeMirror.

BTW, adding this nasty code modalBar._getFirstInput().on("blur", function () { EditorManager.focusEditor(); }); in FindReplacejs#L155 makes the modal work as the Find In Files one.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Thursday Aug 08, 2013 at 01:26 GMT


[edit: never mind, see below]

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Thursday Aug 08, 2013 at 01:27 GMT


Oops, mixed up the bug & pull request -- my bad.

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

No branches or pull requests

1 participant