Title: [207481] trunk/Source/WebInspectorUI
Revision
207481
Author
commit-qu...@webkit.org
Date
2016-10-18 13:21:02 -0700 (Tue, 18 Oct 2016)

Log Message

Web Inspector: CSS Autocompletion sometimes adds extra unexpected characters
https://bugs.webkit.org/show_bug.cgi?id=163612
<rdar://problem/28829557>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2016-10-18
Reviewed by Timothy Hatcher.

* UserInterface/Controllers/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController.prototype._generateCSSCompletions):
Better handle completions in cases where we are in the middle of a property
to avoid orphaned characters, or at the end of a function name to avoid creating
duplicate parenthesis.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (207480 => 207481)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-10-18 20:17:10 UTC (rev 207480)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-10-18 20:21:02 UTC (rev 207481)
@@ -1,5 +1,19 @@
 2016-10-18  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: CSS Autocompletion sometimes adds extra unexpected characters
+        https://bugs.webkit.org/show_bug.cgi?id=163612
+        <rdar://problem/28829557>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/CodeMirrorCompletionController.js:
+        (WebInspector.CodeMirrorCompletionController.prototype._generateCSSCompletions):
+        Better handle completions in cases where we are in the middle of a property
+        to avoid orphaned characters, or at the end of a function name to avoid creating
+        duplicate parenthesis.
+
+2016-10-18  Joseph Pecoraro  <pecor...@apple.com>
+
         REGRESSION(r201171): Web Inspector: Timeline Recording playhead should always start immediately, not wait until first event
         https://bugs.webkit.org/show_bug.cgi?id=163583
         <rdar://problem/28815882>

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (207480 => 207481)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2016-10-18 20:17:10 UTC (rev 207480)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2016-10-18 20:21:02 UTC (rev 207481)
@@ -537,6 +537,10 @@
         if (mainToken.state.state === "media" || mainToken.state.state === "top" || mainToken.state.state === "parens")
             return [];
 
+        // Don't complete in the middle of a property name.
+        if (/^[a-z]/i.test(suffix))
+            return [];
+
         var token = mainToken;
         var lineNumber = this._lineNumber;
 
@@ -561,14 +565,24 @@
             var propertyName = token.string;
 
             // If there is a suffix and it isn't a semicolon, then we should use a space since
-            // the user is editing in the middle.
-            this._implicitSuffix = suffix && suffix !== ";" ? " " : (this._noEndingSemicolon ? "" : ";");
+            // the user is editing in the middle. Likewise if the suffix starts with an open
+            // paren we are changing a function name so don't add a suffix.
+            this._implicitSuffix = " ";
+            if (suffix === ";")
+                this._implicitSuffix = this._noEndingSemicolon ? "" : ";";
+            else if (suffix.startsWith("("))
+                this._implicitSuffix = "";
 
             // Don't use an implicit suffix if it would be the same as the existing suffix.
             if (this._implicitSuffix === suffix)
                 this._implicitSuffix = "";
 
-            return WebInspector.CSSKeywordCompletions.forProperty(propertyName).startsWith(this._prefix);
+            let completions = WebInspector.CSSKeywordCompletions.forProperty(propertyName).startsWith(this._prefix);
+
+            if (suffix.startsWith("("))
+                completions = completions.map((x) => x.replace(/\(\)$/, ""));
+
+            return completions;
         }
 
         this._implicitSuffix = suffix !== ":" ? ": " : "";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to