Bug 200770 - Web Inspector: CodeMirror still inserts a tab even when "Prefer indent using" is set to "Spaces"
Summary: Web Inspector: CodeMirror still inserts a tab even when "Prefer indent using"...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-08-15 09:25 PDT by Devin Rousso
Modified: 2019-08-15 12:33 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.63 KB, patch)
2019-08-15 09:26 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (1.88 KB, patch)
2019-08-15 09:59 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (1.87 KB, patch)
2019-08-15 10:31 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (1.98 KB, patch)
2019-08-15 11:13 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2019-08-15 09:25:31 PDT
# STEPS TO REPRODUCE:
1. inspect any page
2. go to any resource that is editable
3. press tab ↹
 => \t inserted instead of "    " (4)
Comment 1 Devin Rousso 2019-08-15 09:26:45 PDT
Created attachment 376384 [details]
Patch
Comment 2 Ross Kirsling 2019-08-15 09:50:28 PDT
Is this better than having WI make Tab execute `insertSoftTab` and specify `options.tabSize` appropriately?
Comment 3 Devin Rousso 2019-08-15 09:55:54 PDT
(In reply to Ross Kirsling from comment #2)
> Is this better than having WI make Tab execute `insertSoftTab` and specify `options.tabSize` appropriately?
I didn't even know that was a thing!  I'll give it a shot =D
Comment 4 Devin Rousso 2019-08-15 09:59:01 PDT
Created attachment 376387 [details]
Patch
Comment 5 Ross Kirsling 2019-08-15 10:23:35 PDT
Comment on attachment 376387 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=376387&action=review

It's still a bit sad to me, but I guess it's how we've got to do it:
https://github.com/codemirror/CodeMirror/pull/4317

> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:624
> +        CodeMirror.commands.insertTab = function(cm) {

Maybe it'd still be better to overwrite `defaultTab`, so that you don't have to store `original`?

> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:625
> +            if (WI.settings.indentWithTabs.value)

I think this can be `cm.options.indentWithTabs`, given all this:
https://github.com/WebKit/webkit/blob/master/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js#L36-L58
Comment 6 Devin Rousso 2019-08-15 10:29:58 PDT
Comment on attachment 376387 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=376387&action=review

>> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:624
>> +        CodeMirror.commands.insertTab = function(cm) {
> 
> Maybe it'd still be better to overwrite `defaultTab`, so that you don't have to store `original`?

I'd rather not, as that would require that I duplicate the `if (cm.somethingSelected()) { cm.indentSelection("add") }` logic, which adds complexity and potential confusion each time we update CodeMirror.

>> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:625
>> +            if (WI.settings.indentWithTabs.value)
> 
> I think this can be `cm.options.indentWithTabs`, given all this:
> https://github.com/WebKit/webkit/blob/master/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js#L36-L58

Good point.  I'll switch.
Comment 7 Devin Rousso 2019-08-15 10:31:44 PDT
Created attachment 376390 [details]
Patch
Comment 8 Ross Kirsling 2019-08-15 10:36:17 PDT
(In reply to Devin Rousso from comment #6)
> I'd rather not, as that would require that I duplicate the `if
> (cm.somethingSelected()) { cm.indentSelection("add") }` logic, which adds
> complexity and potential confusion each time we update CodeMirror.

Even with this solution though, I wonder if a comment would be in order to encourage us to keep an eye on it across CodeMirror updates? (Maybe we could link to the PR as a justification for why we had to go this route.)
Comment 9 Ross Kirsling 2019-08-15 10:36:31 PDT
Comment on attachment 376390 [details]
Patch

r=me otherwise
Comment 10 Devin Rousso 2019-08-15 11:13:48 PDT
Created attachment 376396 [details]
Patch
Comment 11 WebKit Commit Bot 2019-08-15 12:32:21 PDT
Comment on attachment 376396 [details]
Patch

Clearing flags on attachment: 376396

Committed r248739: <https://trac.webkit.org/changeset/248739>
Comment 12 WebKit Commit Bot 2019-08-15 12:32:22 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2019-08-15 12:33:17 PDT
<rdar://problem/54358187>