RESOLVED FIXED194796
Web Inspector: Styles: Control-Space should force completion
https://bugs.webkit.org/show_bug.cgi?id=194796
Summary Web Inspector: Styles: Control-Space should force completion
Nikita Vasilyev
Reported 2019-02-18 15:29:26 PST
Pressing Control-Space should show completion popover, even if the value is empty. This is how it works in Xcode, Chrome DevTools, and just about every code editor.
Attachments
Patch (4.81 KB, patch)
2019-02-18 15:32 PST, Nikita Vasilyev
mattbaker: review-
[Video] With patch applied (651.26 KB, video/quicktime)
2019-02-18 15:32 PST, Nikita Vasilyev
no flags
Patch (5.43 KB, patch)
2019-02-22 14:00 PST, Nikita Vasilyev
no flags
Patch (5.68 KB, patch)
2019-02-26 17:19 PST, Nikita Vasilyev
mattbaker: review+
Patch for landing (5.64 KB, patch)
2019-02-28 12:41 PST, Nikita Vasilyev
no flags
Radar WebKit Bug Importer
Comment 1 2019-02-18 15:30:24 PST
Nikita Vasilyev
Comment 2 2019-02-18 15:32:19 PST
Nikita Vasilyev
Comment 3 2019-02-18 15:32:40 PST
Created attachment 362350 [details] [Video] With patch applied
Matt Baker
Comment 4 2019-02-18 15:36:34 PST
One thing I find really annoying is pressing Escape in the TextEditor shows the completion popover, for a file that is probably read-only, when it would be so much better to focus the Quick Console instead. If control-space is a common shortcut for showing autocompletion, can we free up escape for this?
Nikita Vasilyev
Comment 5 2019-02-18 15:41:03 PST
(In reply to Matt Baker from comment #4) > One thing I find really annoying is pressing Escape in the TextEditor shows > the completion popover, for a file that is probably read-only, when it would > be so much better to focus the Quick Console instead. We shouldn't autocomplete for read-only resources, period. > > If control-space is a common shortcut for showing autocompletion, can we > free up escape for this? I think it makes sense. I'd prefer to do it as a separate patch since it's unrelated to the styles sidebar.
Matt Baker
Comment 6 2019-02-18 15:47:48 PST
(In reply to Matt Baker from comment #4) > One thing I find really annoying is pressing Escape in the TextEditor shows > the completion popover, for a file that is probably read-only, when it would > be so much better to focus the Quick Console instead. Actually it's only an issue for local files. Also I couldn't ever get the focus to jump to the Quick Console, so maybe that was never a thing. > If control-space is a common shortcut for showing autocompletion, can we > free up escape for this? I think the case we actually want to consider is autocomplete in the Quick Console. Escape is the shortcut for both show/hide console drawer, and show/dismiss autocomplete. I think we should only use control-space to show autocomplete. What do you think?
Matt Baker
Comment 7 2019-02-18 15:48:23 PST
(In reply to Nikita Vasilyev from comment #5) > (In reply to Matt Baker from comment #4) > > One thing I find really annoying is pressing Escape in the TextEditor shows > > the completion popover, for a file that is probably read-only, when it would > > be so much better to focus the Quick Console instead. > > We shouldn't autocomplete for read-only resources, period. > > > > > If control-space is a common shortcut for showing autocompletion, can we > > free up escape for this? > > I think it makes sense. I'd prefer to do it as a separate patch since it's > unrelated to the styles sidebar. Makes sense!
Matt Baker
Comment 8 2019-02-19 20:37:46 PST
Comment on attachment 362349 [details] Patch r- for now, because completions for property values are currently broken, making this difficult to review. The completions popover is no longer shown when tabbing to a new property value from a property name. This regressed in https://webkit.org/b/193605. I think it makes sense to fix the behavior as part of this patch, since they are so closely related.
Matt Baker
Comment 9 2019-02-19 20:44:06 PST
Comment on attachment 362349 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=362349&action=review > Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:372 > + _updateCompletions(forceCompletions = false) It would be great if we could avoid passing this flag across so many functions.
Nikita Vasilyev
Comment 10 2019-02-22 14:00:19 PST
Nikita Vasilyev
Comment 11 2019-02-22 14:00:42 PST
(In reply to Matt Baker from comment #8) > Comment on attachment 362349 [details] > Patch > > r- for now, because completions for property values are currently broken, > making this difficult to review. > > The completions popover is no longer shown when tabbing to a new property > value from a property name. This regressed in https://webkit.org/b/193605. I > think it makes sense to fix the behavior as part of this patch, since they > are so closely related. Fixed!
Nikita Vasilyev
Comment 12 2019-02-22 14:07:19 PST
(In reply to Matt Baker from comment #9) > Comment on attachment 362349 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=362349&action=review > > > Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:372 > > + _updateCompletions(forceCompletions = false) > > It would be great if we could avoid passing this flag across so many > functions. I don't think I can avoid it. We don't show completion popover for empty CSS property names (e.g. when creating a new property). I think it makes sense because at the top of the list are obscure -apple- and -epub- properties. I'm fine with showing completion popover for empty property names after this bug lands: Bug 156271 - Web Inspector: CSS autocomplete: suggestion hint should be the most commonly used property and not the alphabetically first one.
Devin Rousso
Comment 13 2019-02-25 17:32:35 PST
Comment on attachment 362761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=362761&action=review > Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js:268 > + if (prefix === "") NIT: `!prefix`. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:712 > + _nameCompletionDataProvider(prefix, forceCompletion = false) I'd prefer you put this inside an optional `options` object and rename it to a positive. _nameCompletionDataProvider(prefix, options = {}) let completions = null; if (!prefix && options.allowEmptyPrefix) completions = WI.CSSCompletions.cssNameCompletions.values; else completions = WI.CSSCompletions.cssNameCompletions.startsWith(prefix); > Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:716 > + if (!prefix && forceCompletion) > + completions = WI.CSSCompletions.cssNameCompletions.values; If `forceCompletion` is `false`, both of these paths will have the same effect. If we show all values when `prefix` is empty, all we really need to do is force the completion popover to appear when ⌃-Space is pressed. `forceCompletion` is unnecessary. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:719 > + NIT: unnecessary newline. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:-750 > - completions: WI.CSSKeywordCompletions.forProperty(propertyName).startsWith(prefix) Why was this changed? Having it inline is fine. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:281 > + if (event.ctrlKey && event.code === "Space") { We should decide on <https://webkit.org/b/192947> before doing this. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:378 > + let {completions, prefix} = this._completionProvider(valueWithoutSuggestion, forceCompletions); You also need to update `WI.SpreadsheetStyleProperty.prototype._valueCompletionDataProvider` for this.
Nikita Vasilyev
Comment 14 2019-02-25 17:51:25 PST
Comment on attachment 362761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=362761&action=review >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:716 >> + completions = WI.CSSCompletions.cssNameCompletions.values; > > If `forceCompletion` is `false`, both of these paths will have the same effect. If we show all values when `prefix` is empty, all we really need to do is force the completion popover to appear when ⌃-Space is pressed. `forceCompletion` is unnecessary. "If `forceCompletion` is `false`, both of these paths will have the same effect." — no, they won't. We don't show completion popover for empty CSS property names (e.g. when creating a new property).
Devin Rousso
Comment 15 2019-02-25 18:44:32 PST
Comment on attachment 362761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=362761&action=review >>> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:716 >>> + completions = WI.CSSCompletions.cssNameCompletions.values; >> >> If `forceCompletion` is `false`, both of these paths will have the same effect. If we show all values when `prefix` is empty, all we really need to do is force the completion popover to appear when ⌃-Space is pressed. `forceCompletion` is unnecessary. > > "If `forceCompletion` is `false`, both of these paths will have the same effect." — no, they won't. > We don't show completion popover for empty CSS property names (e.g. when creating a new property). Ah, I missed the part where `_acceptEmptyPrefix` gets set. Why is it that we don't want to show a completion for an empty property name? Is it just because there are a lot of CSS properties? If we're adding a keyboard shortcut to force completions, but only for values, that seems a bit strict.
Nikita Vasilyev
Comment 16 2019-02-25 18:52:53 PST
Because this is what it shows for empty property names: -apple-color-filter -apple-pay-button-style -apple-pay-button-type -apple-trailing-word -epub-caption-side -epub-hyphens -epub-text-combine -epub-text-emphasis -epub-text-emphasis-color -epub-text-emphasis-style -epub-text-orientation I'm to show completions for empty property names once we land your patch to show the most commonly used properties first.
Nikita Vasilyev
Comment 17 2019-02-26 17:19:26 PST
Nikita Vasilyev
Comment 18 2019-02-27 12:13:55 PST
(In reply to Nikita Vasilyev from comment #16) > I'm to show completions for empty property names once we land your patch to > show the most commonly used properties first. *I'm fine with showing
Matt Baker
Comment 19 2019-02-28 12:24:29 PST
(In reply to Nikita Vasilyev from comment #16) > Because this is what it shows for empty property names: > > -apple-color-filter > -apple-pay-button-style > -apple-pay-button-type > -apple-trailing-word > -epub-caption-side > -epub-hyphens > -epub-text-combine > -epub-text-emphasis > -epub-text-emphasis-color > -epub-text-emphasis-style > -epub-text-orientation > > I'm to show completions for empty property names once we land your patch to > show the most commonly used properties first. I'm not sure we want to do this. The user probably isn't adding a new CSS property unless they have at least an idea of what the property is, even if they can't remember, say, how to spell it. Sorting the list by commonly used properties will surface useful properties some of the time, but it is still distracting at best IMO.
Matt Baker
Comment 20 2019-02-28 12:35:18 PST
Comment on attachment 363042 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363042&action=review r=me > Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:379 > + const options = {allowEmptyPrefix: forceCompletions}; This can be inlined: let {completions, prefix} = this._completionProvider(valueWithoutSuggestion, {allowEmptyPrefix: forceCompletions});
Nikita Vasilyev
Comment 21 2019-02-28 12:41:13 PST
Created attachment 363252 [details] Patch for landing
WebKit Commit Bot
Comment 22 2019-02-28 13:19:30 PST
Comment on attachment 363252 [details] Patch for landing Clearing flags on attachment: 363252 Committed r242218: <https://trac.webkit.org/changeset/242218>
WebKit Commit Bot
Comment 23 2019-02-28 13:19:32 PST
All reviewed patches have been landed. Closing bug.
Nikita Vasilyev
Comment 24 2019-03-14 13:56:43 PDT
*** Bug 182471 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.