-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web Inspector: CSS source editor can adopt fuzzy search for code comp…
…letion rdar://125030691 https://bugs.webkit.org/show_bug.cgi?id=271260 Reviewed by Devin Rousso. Use CSSCompletions.executeQuery instead of CSSCompletions.startsWith when language mode is CSS, since executeQuery uses fuzzy search. Also add an setting item in the Settings tab's Experimental sub-tab to optionally turn this feature off. * Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js: (WI.CodeMirrorCompletionController.prototype._generateCSSCompletions): - Optionally apply fuzzy search by using `executeQuery`. (WI.CodeMirrorCompletionController.prototype.updateCompletions): - The argument `completions` could now also be an array of objects instead of always an array of strings (due to executeQuery returning an array of objects). Those objects also contain info on which characters match in the fuzzy search, so the suggestion box can bold the matching text. `this._completions` however does not need this extra info, so we extract only the texts from `completions` for that. (WI.CodeMirrorCompletionController.prototype._applyCompletionHint): (WI.CodeMirrorCompletionController.prototype._applyCompletionHint.update): - Fuzzy search can now match completions not necessarily starting with the same text as currentText. Only show the gray watermark text (hint marker in code) when it's actually a prefix match. * Source/WebInspectorUI/UserInterface/Models/Completions.js: Added. * Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js: (WI.CSSCompletions.getCompletionText): - As the getCompletionText helper function doesn't have to work for only CSS suggestions, it better belongs to a class with a more generic name like Completion instead of CSSCompletion. - Leave a note to eventually migrate all other usages of the old CSSCompletion.getCompletionText to Completion.getCompletionText. * Source/WebInspectorUI/UserInterface/Main.html: * Source/WebInspectorUI/UserInterface/Test.html: - Include the new Completions.js source file. * Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js: * Source/WebInspectorUI/UserInterface/Base/Setting.js: * Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js: - Add an experimental setting item for this feature change. Canonical link: https://commits.webkit.org/279144@main
- Loading branch information
1 parent
ac7aecf
commit e058a9c
Showing
8 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2024 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
WI.Completions = class Completions | ||
{ | ||
// Static | ||
|
||
static getCompletionText(completion) | ||
{ | ||
if (typeof completion === "string") | ||
return completion; | ||
|
||
if (completion instanceof WI.QueryResult) | ||
return completion.value; | ||
|
||
console.assert(false, "completion should be either String or WI.QueryResult; got", completion); | ||
return ""; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters