Diff
Modified: trunk/LayoutTests/inspector/unit-tests/css-keyword-completions.html (295558 => 295559)
--- trunk/LayoutTests/inspector/unit-tests/css-keyword-completions.html 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/LayoutTests/inspector/unit-tests/css-keyword-completions.html 2022-06-15 15:34:26 UTC (rev 295559)
@@ -23,9 +23,11 @@
if (expectedCompletionCount >= 0)
InspectorTest.expectEqual(completionResults.completions.length, expectedCompletionCount, `Expected exactly ${expectedCompletionCount} completion results.`);
+ let completionStrings = completionResults.completions.map((completion) => WI.CSSCompletions.getCompletionText(completion));
+
// Because expected completions could be added at any time, just make sure the list contains our expected completions, instead of enforcing an exact match between expectations and reality.
let expectedCompletionsPresent = expectedCompletions.every((expectedCompletion) => {
- if (!completionResults.completions.includes(expectedCompletion)) {
+ if (!completionStrings.includes(expectedCompletion)) {
InspectorTest.fail(`Expected completion "${expectedCompletion}" in completions.`);
return false;
}
@@ -92,9 +94,11 @@
if (expectedCompletionCount >= 0)
InspectorTest.expectEqual(completionResults.completions.length, expectedCompletionCount, `Expected exactly ${expectedCompletionCount} completion results.`);
+ let completionStrings = completionResults.completions.map((completion) => WI.CSSCompletions.getCompletionText(completion));
+
// Because expected completions could be added at any time, just make sure the list contains our expected completions, instead of enforcing an exact match between expectations and reality.
let expectedCompletionsPresent = expectedCompletions.every((expectedCompletion) => {
- if (!completionResults.completions.includes(expectedCompletion)) {
+ if (!completionStrings.includes(expectedCompletion)) {
InspectorTest.fail(`Expected completion "${expectedCompletion}" in completions.`);
return false;
}
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -1669,7 +1669,6 @@
localizedStrings["Use Default Appearance"] = "Use Default Appearance";
localizedStrings["Use Mock Capture Devices"] = "Use Mock Capture Devices";
localizedStrings["Use default media styles"] = "Use default media styles";
-localizedStrings["Use fuzzy matching for completion suggestions"] = "Use fuzzy matching for completion suggestions";
localizedStrings["User Agent"] = "User Agent";
localizedStrings["User Agent Style Sheet"] = "User Agent Style Sheet";
localizedStrings["User Agent:"] = "User Agent:";
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -231,7 +231,6 @@
experimentalEnableStylesJumpToEffective: new WI.Setting("experimental-styles-jump-to-effective", false),
experimentalEnableStylesJumpToVariableDeclaration: new WI.Setting("experimental-styles-jump-to-variable-declaration", false),
experimentalAllowInspectingInspector: new WI.Setting("experimental-allow-inspecting-inspector", false),
- experimentalCSSCompletionFuzzyMatching: new WI.Setting("experimental-css-completion-fuzzy-matching", true),
experimentalCSSSortPropertyNameAutocompletionByUsage: new WI.Setting("experimental-css-sort-property-name-autocompletion-by-usage", true),
// Protocol
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -131,6 +131,19 @@
return suffix;
}
+ static getCompletionText(completion)
+ {
+ console.assert(typeof completion === "string" || completion instanceof WI.QueryResult, completion);
+
+ if (typeof completion === "string")
+ return completion;
+
+ if (completion instanceof WI.QueryResult)
+ return completion.value;
+
+ return "";
+ }
+
// Public
get values()
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -31,7 +31,7 @@
WI.CSSKeywordCompletions = {};
-WI.CSSKeywordCompletions.forPartialPropertyName = function(text, {caretPosition, allowEmptyPrefix, useFuzzyMatching} = {})
+WI.CSSKeywordCompletions.forPartialPropertyName = function(text, {caretPosition, allowEmptyPrefix} = {})
{
allowEmptyPrefix ??= false;
@@ -42,16 +42,10 @@
if (!text.length && allowEmptyPrefix)
return {prefix: text, completions: WI.cssManager.propertyNameCompletions.values};
- let completions;
- if (useFuzzyMatching)
- completions = WI.cssManager.propertyNameCompletions.executeQuery(text);
- else
- completions = WI.cssManager.propertyNameCompletions.startsWith(text);
-
- return {prefix: text, completions};
+ return {prefix: text, completions: WI.cssManager.propertyNameCompletions.executeQuery(text)};
};
-WI.CSSKeywordCompletions.forPartialPropertyValue = function(text, propertyName, {caretPosition, additionalFunctionValueCompletionsProvider, useFuzzyMatching} = {})
+WI.CSSKeywordCompletions.forPartialPropertyValue = function(text, propertyName, {caretPosition, additionalFunctionValueCompletionsProvider} = {})
{
caretPosition ??= text.length;
@@ -130,13 +124,7 @@
else
valueCompletions = WI.CSSKeywordCompletions.forProperty(propertyName);
- let completions;
- if (useFuzzyMatching)
- completions = valueCompletions.executeQuery(currentTokenValue);
- else
- completions = valueCompletions.startsWith(currentTokenValue);
-
- return {prefix: currentTokenValue, completions};
+ return {prefix: currentTokenValue, completions: valueCompletions.executeQuery(currentTokenValue)};
};
WI.CSSKeywordCompletions.forProperty = function(propertyName)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -80,7 +80,7 @@
}
if (this._completions[this._selectedIndex])
- this._delegate?.completionSuggestionsSelectedCompletion?.(this, this.getCompletionText(this._completions[this._selectedIndex]));
+ this._delegate?.completionSuggestionsSelectedCompletion?.(this, WI.CSSCompletions.getCompletionText(this._completions[this._selectedIndex]));
}
selectNext()
@@ -190,19 +190,6 @@
}
}
- getCompletionText(completion)
- {
- console.assert(typeof completion === "string" || completion instanceof WI.QueryResult, completion);
-
- if (typeof completion === "string")
- return completion;
-
- if (completion instanceof WI.QueryResult)
- return completion.value;
-
- return "";
- }
-
// Private
get _selectedItemElement()
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -391,7 +391,6 @@
let stylesGroup = experimentalSettingsView.addGroup(WI.UIString("Styles:"));
stylesGroup.addSetting(WI.settings.experimentalEnableStylesJumpToEffective, WI.UIString("Show jump to effective property button"));
stylesGroup.addSetting(WI.settings.experimentalEnableStylesJumpToVariableDeclaration, WI.UIString("Show jump to variable declaration button"));
- stylesGroup.addSetting(WI.settings.experimentalCSSCompletionFuzzyMatching, WI.UIString("Use fuzzy matching for completion suggestions"));
stylesGroup.addSetting(WI.settings.experimentalCSSSortPropertyNameAutocompletionByUsage, WI.UIString("Suggest property names based on usage"));
experimentalSettingsView.addSeparator();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js (295558 => 295559)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js 2022-06-15 14:51:31 UTC (rev 295558)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js 2022-06-15 15:34:26 UTC (rev 295559)
@@ -430,9 +430,8 @@
if (!this._completionProvider)
return;
- let useFuzzyMatching = WI.settings.experimentalCSSCompletionFuzzyMatching.value;
let valueWithoutSuggestion = this.valueWithoutSuggestion();
- let {completions, prefix} = this._completionProvider(valueWithoutSuggestion, {allowEmptyPrefix: forceCompletions, caretPosition: this._getCaretPosition(), useFuzzyMatching});
+ let {completions, prefix} = this._completionProvider(valueWithoutSuggestion, {allowEmptyPrefix: forceCompletions, caretPosition: this._getCaretPosition()});
this._completionPrefix = prefix;
if (!completions.length) {
@@ -441,7 +440,7 @@
}
// No need to show the completion popover with only one item that matches the entered value.
- if (completions.length === 1 && this._suggestionsView.getCompletionText(completions[0]) === valueWithoutSuggestion) {
+ if (completions.length === 1 && WI.CSSCompletions.getCompletionText(completions[0]) === valueWithoutSuggestion) {
this.discardCompletion();
return;
}
@@ -454,7 +453,7 @@
this._suggestionsView.update(completions);
- if (completions.length === 1 && this._suggestionsView.getCompletionText(completions[0]).startsWith(this._completionPrefix)) {
+ if (completions.length === 1 && WI.CSSCompletions.getCompletionText(completions[0]).startsWith(this._completionPrefix)) {
// No need to show the completion popover with only one item that begins with the completion prefix.
// When using fuzzy matching, the completion prefix may not occur at the beginning of the suggestion.
this._suggestionsView.hide();
@@ -464,7 +463,7 @@
this._suggestionsView.selectedIndex = NaN;
if (this._completionPrefix) {
if (this._delegate?.spreadsheetTextFieldInitialCompletionIndex)
- this._suggestionsView.selectedIndex = this._delegate.spreadsheetTextFieldInitialCompletionIndex(this, completions.map((completion) => this._suggestionsView.getCompletionText(completion)));
+ this._suggestionsView.selectedIndex = this._delegate.spreadsheetTextFieldInitialCompletionIndex(this, completions.map((completion) => WI.CSSCompletions.getCompletionText(completion)));
else
this._suggestionsView.selectNext();
} else