Changeset 291740 in webkit
- Timestamp:
- Mar 23, 2022 1:40:10 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/unit-tests/css-keyword-completions-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/unit-tests/css-keyword-completions.html (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291737 r291740 1 2022-03-23 Razvan Caliman <rcaliman@apple.com> 2 3 Web Inspector: Styles panel: Unwanted extra dash when autocompleting CSS variable names 4 https://bugs.webkit.org/show_bug.cgi?id=237676 5 6 Reviewed by Patrick Angle. 7 8 Add tests for special cases of matching incomplete CSS variable names in autocompletion. 9 10 * inspector/unit-tests/css-keyword-completions-expected.txt: 11 * inspector/unit-tests/css-keyword-completions.html: 12 1 13 2022-03-22 Ben Nham <nham@apple.com> 2 14 -
trunk/LayoutTests/inspector/unit-tests/css-keyword-completions-expected.txt
r287934 r291740 72 72 PASS: All expected completions were present. 73 73 74 -- Running test case: WI.CSSKeywordCompletions.forPartialPropertyValue.InvalidVariableName 75 PASS: Expected result prefix to be "-x" 76 PASS: All expected completions were present. 77 78 -- Running test case: WI.CSSKeywordCompletions.forPartialPropertyValue.IncompleteVariableName 79 PASS: Expected result prefix to be "--" 80 PASS: All expected completions were present. 81 82 -- Running test case: WI.CSSKeywordCompletions.forPartialPropertyValue.DashedEnvironmentVariableName 83 PASS: Expected result prefix to be "--" 84 PASS: All expected completions were present. 85 86 -- Running test case: WI.CSSKeywordCompletions.forPartialPropertyValue.VendorPrefixedValue 87 PASS: Expected result prefix to be "-webkit" 88 PASS: All expected completions were present. 89 90 -- Running test case: WI.CSSKeywordCompletions.forPartialPropertyValue.SubtractionCalc 91 PASS: Expected result prefix to be "" 92 PASS: All expected completions were present. 93 74 94 -- Running test case: WI.CSSKeywordCompletions.forPartialPropertyValue.VariableFunctionInCalc 75 95 PASS: Expected result prefix to be "" -
trunk/LayoutTests/inspector/unit-tests/css-keyword-completions.html
r287934 r291740 232 232 }); 233 233 234 // `var(-x|` 235 addTestForPartialPropertyValue({ 236 name: "WI.CSSKeywordCompletions.forPartialPropertyValue.InvalidVariableName", 237 description: "Test that an invalid variable name is still used as a prefix", 238 text: "var(-x", 239 expectedPrefix: "-x", 240 expectedCompletions: [], 241 }); 242 243 // `var(--|` 244 addTestForPartialPropertyValue({ 245 name: "WI.CSSKeywordCompletions.forPartialPropertyValue.IncompleteVariableName", 246 description: "Test that an incomplete variable name is still used as a prefix", 247 text: "var(--", 248 expectedPrefix: "--", 249 expectedCompletions: [], 250 }); 251 252 // `env(--|` 253 addTestForPartialPropertyValue({ 254 name: "WI.CSSKeywordCompletions.forPartialPropertyValue.DashedEnvironmentVariableName", 255 description: "Test that a dashed name used within env() is entirely used as a prefix", 256 text: "env(--", 257 expectedPrefix: "--", 258 expectedCompletions: [], 259 }); 260 261 // `-webkit|` 262 addTestForPartialPropertyValue({ 263 name: "WI.CSSKeywordCompletions.forPartialPropertyValue.VendorPrefixedValue", 264 description: "Test that a value that looks vendor-prefixed is entirely used as a prefix", 265 propertyName: "display", 266 text: "-webkit", 267 expectedPrefix: "-webkit", 268 expectedCompletions: ["-webkit-flex"], 269 }); 270 271 // `calc(1 - |` 272 addTestForPartialPropertyValue({ 273 name: "WI.CSSKeywordCompletions.forPartialPropertyValue.SubtractionCalc", 274 description: "Test that a whitespace-separated minus sign in calc() isn't included in the prefix", 275 text: "calc(1 - ", 276 expectedPrefix: "", 277 expectedCompletions: [], 278 }); 279 234 280 // `calc(1 + var(|))` 235 281 addTestForPartialPropertyValue({ -
trunk/Source/WebInspectorUI/ChangeLog
r291729 r291740 1 2022-03-23 Razvan Caliman <rcaliman@apple.com> 2 3 Web Inspector: Styles panel: Unwanted extra dash when autocompleting CSS variable names 4 https://bugs.webkit.org/show_bug.cgi?id=237676 5 6 Reviewed by Patrick Angle. 7 8 The CSS-mode tokenizer provided by CodeMirror and used in Web Inspector matches strictly conforming 9 CSS variable names, i.e. prefixed with two dahses, `--`. 10 11 An identifier like `-name` gets split into two tokens `-` and `name`. 12 The token at the cursor position becomes just `name`. 13 This token's value is used as a query string for autocompletion. 14 15 When a completion suggestion is picked, the query string gets replaced with the suggestion text in 16 `WI.SpreadsheetTextField._updatePendingValueWithCompletionText()`. 17 But because it was split from the query, the dash ends up prepended to the replaced string. 18 19 This patch adds a special case in `WI.CSSKeywordCompletions.forPartialPropertyValue()` 20 to account for this aspect of the tokenizer. 21 22 * UserInterface/Models/CSSKeywordCompletions.js: 23 1 24 2022-03-22 Patrick Angle <pangle@apple.com> 2 25 -
trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js
r287934 r291740 101 101 if (currentTokenValue === ")" || tokenBeforeCaret?.value === ")") 102 102 return {prefix: "", completions: []}; 103 104 // The CodeMirror CSS-mode tokenizer splits a string like `-name` into two tokens: `-` and `name`. 105 if (currentTokenValue.length && tokenBeforeCaret?.value === "-") { 106 currentTokenValue = tokenBeforeCaret.value + currentTokenValue; 107 } 103 108 104 109 let functionName = null;
Note: See TracChangeset
for help on using the changeset viewer.