Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

[ARCH] Impossible for extensions to override Tab key behavior where code hints might be open #4660

Closed
peterflynn opened this issue Aug 6, 2013 · 9 comments

Comments

@peterflynn
Copy link
Member

  1. Install the Emmet extension
  2. In a CSS selector, type "b" and press Tab
  3. Clear the line. Type "b" again, but press Escape to close code hints before pressing Tab

Result:
When code hints are open, Tab selects the top item, inserting backface-visibility:|.
When code hints not open, Tab does the Emmet behavior, inserting bottom: |;.

Expected:
We should allow extensions to override key handling in the editor area even when code hints are (potentially) open, since code hints appear almost all the time when typing.

I have a similar case for JS snippets. E.g. I'd like to be able to type "clog"+Tab and get console.log("|"); inserted. But because JS code hints always come up with a camelcase suggestion of localStorage, this is blocked by code hints 100% of the time.

This used to work, but I think it broke in Sprint 26 when fba13c2 switched code hints to a "global keydown hook" which, once installed at the time the hints open, is effectively impossible to override. I looked into many ways of getting around this hook, but afaict it is 100% impossible. (There's not even an easy way to install your own higher-precedence global hook, since there's no notification to tell you when code hints have been opened).

@peterflynn
Copy link
Member Author

CC @njx since he wrote the "global keydown hook" code in question, and @RaymondLim since I know he thinks about keyboard stuff a lot.

@JeffryBooher
Copy link
Contributor

Moving this to Backlog to consider with API enhancements card.
https://trello.com/c/rnN0XwK0/876-3-research-extension-api-design

@peterflynn
Copy link
Member Author

This is definitely out of scope for that story (we decided in Monday's arch meeting that no specific APIs would be considered -- only broad strokes). Reopening but leaving tagged MTB so we can find this a more suitable home on the backlog.

@peterflynn peterflynn reopened this Aug 9, 2013
@njx
Copy link

njx commented Aug 16, 2013

Tagging [ARCH] - it's not totally obvious to me right now what the right fix is and it's probably worth discussing it at the architecture meeting.

@TomMalbran
Copy link
Contributor

What about having priorities on the global keydown hooks? Emmet could then use a keydown hook with a higher priority than the keydown hook used by the Code Hints. Also, the keydown hook should receive a translated key to make it easier to distinguish between "Ctrl/Shift/Alt.. + key" from just "key". It can also receive the event, if is still required.

@peterflynn
Copy link
Member Author

#4904 would render this whole issue moot

@TomMalbran
Copy link
Contributor

The same issue could eventually appear with other keys.

@peterflynn
Copy link
Member Author

Fair point -- and #4963 might eventually allow users to re-enable Tab handling for code hints, which would make even the Tab issue come back for some users. So, leaving open for now.

@pthiess
Copy link
Contributor

pthiess commented Aug 29, 2013

Added a card in Trello, going to close this in here.

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

No branches or pull requests

5 participants