-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Editor scrolls back to top when returning to it after Quick Open #2951
Comments
Reviewed, medium priority seems reasonable, @njx |
Looks somewhat unrelated to #2985 after all. I think the bug here is that the value of getCurrentFullEditor() during the ModalBar ctor isn't necessarily the same as the value of getCurrentFullEditor() during ModalBar.close(). Because closing happens at the end of QuickOpen._handleItemSelect() and is further delayed by a timeout, it's basically guaranteed that the editor will have already switched by the time close() is called. Things brings two questions to mind:
|
Also note: the timing of this stuff is affected by whether file B is already in the working set -- the editor switch is much more synchronous if so. |
using Quick Open) - Block re-entrant focus attempts. This bug occurs with any blur handlers that call EditorManager.focusEditor(), since that can cause such re-entrant focus attempts (with two different editors). Blur handlers run synchronously while an editor is in the middle of getting focus, so the state is a little funny - activeEditor hasn't been updated yet (blur fires before focus), so focusEditor() tries to focus the old Editor that's in the process of losing focus. Webkit seems to ignore tht attempt; but CodeMirror assumes that programmatic focus requests always succeed, so CodeMirror's state.focused flag becomes wrong. This has a delayed effect the NEXT time that editor gains focus: it doesn't dispatch a focus event since CM thought it already had focus; as a result, activeEditor never updates and any code that uses activeEditor gets the wrong value. I think we could fix this by triggering stuff on focusIn instead of blur (which is how ModalBar works and why the Find bar doesn't have a similar bug). But it seems safer just to cut it off at the root: re-entrant attempts to focus Editors.
I can still reliably reproduce this after the landing of #3023, so I guess you're right about it not being quite related. |
Nominating for sprint 22. |
Turns out this is due to a subtle race condition: if you call |
FBNC to @peterflynn |
Confirmed |
Finally nailed down some repro steps for this!
The text was updated successfully, but these errors were encountered: