Bug 270578 - Web Inspector: cannot type Option-D with certain keyboard layout in console
Summary: Web Inspector: cannot type Option-D with certain keyboard layout in console
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: Safari 17
Hardware: Mac (Intel) macOS 14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-03-06 09:49 PST by i
Modified: 2024-03-14 10:00 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description i 2024-03-06 09:49:32 PST
In "AZERTY normalisé" keyboard layout, the dollar sign $ is typed with Option+D (https://norme-azerty.fr/en/). However, when I try to type the dollar sign in the Web Inspector console using AZERTY normalisé, no character is inputted, making it impossible to input the dollar sign.

Steps to reproduce:
1. Install "AZERTY normalisé" keyboard layout from https://github.com/cyril-L/french-nf-azerty-mac/releases
2. Switch to this keyboard layout.
3. Open Safari Web Inspector
4. In the Console window, try to press Option+D, and no dollar sign is inputted.
5. In everywhere else, pressing Option+D will give you a dollar sign.
Comment 1 Alexey Proskuryakov 2024-03-06 11:24:16 PST
I think that this can be reproduced even without installing this keyboard. With U.S. keyboard, Option-D normally produces "∂", but nothing in Web Inspector console.
Comment 2 i 2024-03-08 04:28:25 PST
(In reply to Alexey Proskuryakov from comment #1)
> I think that this can be reproduced even without installing this keyboard.
> With U.S. keyboard, Option-D normally produces "∂", but nothing in Web
> Inspector console.

You are right. I use new AZERTY as example because being able to input dollar sign is more important for debugging in console.
Comment 3 Radar WebKit Bug Importer 2024-03-13 10:50:14 PDT
<rdar://problem/124540670>
Comment 4 Razvan Caliman 2024-03-14 04:26:56 PDT
(In reply to Alexey Proskuryakov from comment #1)
> I think that this can be reproduced even without installing this keyboard.
> With U.S. keyboard, Option-D normally produces "∂", but nothing in Web
> Inspector console.

The Console prompt uses the Codemirror editor.

Option-D (aka Alt-D) is a keyboard shortcut which deletes text from the cursor to the end of the word:

https://github.com/WebKit/WebKit/blob/fbe4a30494efb2f9a31d2a6c2866780889869737/Source/WebInspectorUI/UserInterface/External/CodeMirror/codemirror.js#L6321

There are many other keyboard shortcuts which will run editor actions instead of typing in a character.

The reason you don't see the effect is probably because you're trying to type the dollar sign at the start of an empty line.

I don't know if Web Inspector can detect keyboard layout.
Comment 5 Alexey Proskuryakov 2024-03-14 09:01:36 PDT
It's not appropriate to have letter combinations with Option perform commands on macOS with any keyboard layout, those are all in use. I see that Option+B and Option+F are also broken. 

The comment in code saying "which are standard on Mac" is incorrect.
Comment 6 i 2024-03-14 09:20:47 PDT
(In reply to Razvan Caliman from comment #4)
> (In reply to Alexey Proskuryakov from comment #1)
> > I think that this can be reproduced even without installing this keyboard.
> > With U.S. keyboard, Option-D normally produces "∂", but nothing in Web
> > Inspector console.
> 
> The Console prompt uses the Codemirror editor.
> 
> Option-D (aka Alt-D) is a keyboard shortcut which deletes text from the
> cursor to the end of the word:
> 
> https://github.com/WebKit/WebKit/blob/
> fbe4a30494efb2f9a31d2a6c2866780889869737/Source/WebInspectorUI/UserInterface/
> External/CodeMirror/codemirror.js#L6321
> 
> There are many other keyboard shortcuts which will run editor actions
> instead of typing in a character.
> 
> The reason you don't see the effect is probably because you're trying to
> type the dollar sign at the start of an empty line.
> 
> I don't know if Web Inspector can detect keyboard layout.

I found a GitHub issue in CodeMirror's repo that addresses the same problem:  https://github.com/codemirror/codemirror5/issues/6630

Option-D, Option-F and Option-B are legacy emacs shortcuts that no longer work on modern Macs.

CodeMirror already removed Option-D, Option-F and Option-B bindings in https://github.com/codemirror/codemirror5/pull/6631, so the latest CodeMirror does not have this problem.
Comment 7 Qianlang Chen 2024-03-14 10:00:41 PDT
> I found a GitHub issue in CodeMirror's repo that addresses the same problem:
> https://github.com/codemirror/codemirror5/issues/6630
> 
> Option-D, Option-F and Option-B are legacy emacs shortcuts that no longer
> work on modern Macs.
> 
> CodeMirror already removed Option-D, Option-F and Option-B bindings in
> https://github.com/codemirror/codemirror5/pull/6631, so the latest
> CodeMirror does not have this problem.

The CodeMirror we have does seem to be older and didn't include that remove of Option-based shortcuts: https://github.com/WebKit/WebKit/blob/d43c60471f2017c175a36146c61d36c6f104d244/Source/WebInspectorUI/UserInterface/External/CodeMirror/codemirror.js#L6319-L6321