Bug 161514 - Web Inspector: Change Cmd-D from kill line to selecting next occurrence
Summary: Web Inspector: Change Cmd-D from kill line to selecting next occurrence
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: 2016-09-01 15:43 PDT by Devin Rousso
Modified: 2016-09-03 17:40 PDT (History)
7 users (show)

See Also:


Attachments
Patch (25.92 KB, patch)
2016-09-01 18:33 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (26.50 KB, patch)
2016-09-02 14:15 PDT, Devin Rousso
bburg: review+
bburg: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews112 for mac-yosemite (1.43 MB, application/zip)
2016-09-02 15:00 PDT, Build Bot
no flags Details
Patch (26.80 KB, patch)
2016-09-03 17:08 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 2016-09-01 15:43:13 PDT
I often find that when I want to edit the same value in CSS for multiple rules, I try to use Cmd-D to select multiple occurrences (like Sublime Text), but it will delete the line instead.
Comment 1 Radar WebKit Bug Importer 2016-09-01 15:43:38 PDT
<rdar://problem/28125141>
Comment 2 Nikita Vasilyev 2016-09-01 16:01:29 PDT
(In reply to comment #0)
> I often find that when I want to edit the same value in CSS for multiple
> rules, I try to use Cmd-D to select multiple occurrences (like Sublime
> Text), but it will delete the line instead.

Chrome DevTools do the same as Sublime Text.

In Xcode, Command-D does nothing for text and duplicates an item in Interface Builder.
http://stackoverflow.com/questions/10266170/xcode-duplicate-line
Comment 3 BJ Burg 2016-09-01 16:08:10 PDT
Sounds fine to me. As Nikita said, Cmd-D does not have any system-wide significance. The more cross-platform (emacs binding) way to kill a line is Ctrl-K.
Comment 4 Devin Rousso 2016-09-01 18:33:18 PDT
Created attachment 287711 [details]
Patch
Comment 5 BJ Burg 2016-09-02 10:08:44 PDT
Comment on attachment 287711 [details]
Patch

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

The rebinding is fine but I cannot tell what the other effects of this patch are.

> Source/WebInspectorUI/ChangeLog:3
> +        Web Inspector: Change Cmd-D from kill line to selecting next occurance

Please fix bug title with correct spelling prior to landing.

> Source/WebInspectorUI/UserInterface/External/CodeMirror/sublime.js:581
> +  CodeMirror.normalizeKeyMap(map);

I really wish we had a test that dumped out the normalized key map so we could see concretely what keybindings change when we add a new extension like this. It introduces a ton of new bindings, some of which might conflict (or not).

Do you think you could write such a test?
Comment 6 BJ Burg 2016-09-02 10:47:59 PDT
Comment on attachment 287711 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/External/CodeMirror/sublime.js:581
>> +  CodeMirror.normalizeKeyMap(map);
> 
> I really wish we had a test that dumped out the normalized key map so we could see concretely what keybindings change when we add a new extension like this. It introduces a ton of new bindings, some of which might conflict (or not).
> 
> Do you think you could write such a test?

EDIT: filed https://bugs.webkit.org/show_bug.cgi?id=161536. This is out of scope for this change since it depends on UI tests probably.
Comment 7 Joseph Pecoraro 2016-09-02 10:51:01 PDT
Comment on attachment 287711 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Main.html:223
> +    <script src="External/CodeMirror/sublime.js"></script>

Please add this to:
Source/WebInspectorUI/Scripts/update-codemirror-resources.rb

So when we update CodeMirror (I tend to use that script) we get any updates to this file as well.
Comment 8 Devin Rousso 2016-09-02 14:15:44 PDT
Created attachment 287812 [details]
Patch
Comment 9 Build Bot 2016-09-02 15:00:24 PDT
Comment on attachment 287812 [details]
Patch

Attachment 287812 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1996419

New failing tests:
fast/dom/HTMLFormElement/document-deactivation-callback-crash.html
Comment 10 Build Bot 2016-09-02 15:00:27 PDT
Created attachment 287820 [details]
Archive of layout-test-results from ews112 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 11 BJ Burg 2016-09-03 14:27:47 PDT
Comment on attachment 287812 [details]
Patch

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

r=me but please address comments prior to landing.

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTextKillController.js:-49
> -            "Cmd-D": this._handleTextKillCommand.bind(this, "deleteLine", false),

Later in this file, there is a comment that talks about Cmd-D.

            // An entire line was deleted, including newline (Cmd-D).
            if (change.removed[0].length && !change.removed[1].length) 
                killedText = change.removed[0] + "\n";

I think we should just leave this code in and replace 'Cmd-D' in the comment with 'deleteLine'. If we re-add the command as a different keybinding, it's unlikely someone will know that this code needs to be changed, and the actual logic does not depend on the particular keybinding, obviously.

> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:587
> +        "Cmd-D": "selectNextOccurrence",

I am not familiar with CodeMirror key maps. Do we inherit any other bindings from sublime.js, or just this one that we requested?
Comment 12 Devin Rousso 2016-09-03 17:08:49 PDT
Created attachment 287876 [details]
Patch

(In reply to comment #11)
> I am not familiar with CodeMirror key maps. Do we inherit any other bindings
> from sublime.js, or just this one that we requested?

AFAICT, it seems like we only inherit that specific binding.
Comment 13 WebKit Commit Bot 2016-09-03 17:40:21 PDT
Comment on attachment 287876 [details]
Patch

Clearing flags on attachment: 287876

Committed r205414: <http://trac.webkit.org/changeset/205414>
Comment 14 WebKit Commit Bot 2016-09-03 17:40:25 PDT
All reviewed patches have been landed.  Closing bug.