Changeset 207481 in webkit


Ignore:
Timestamp:
Oct 18, 2016 1:21:02 PM (8 years ago)
Author:
commit-queue@webkit.org
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 <Joseph Pecoraro> 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.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r207473 r207481  
     12016-10-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: CSS Autocompletion sometimes adds extra unexpected characters
     4        https://bugs.webkit.org/show_bug.cgi?id=163612
     5        <rdar://problem/28829557>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * UserInterface/Controllers/CodeMirrorCompletionController.js:
     10        (WebInspector.CodeMirrorCompletionController.prototype._generateCSSCompletions):
     11        Better handle completions in cases where we are in the middle of a property
     12        to avoid orphaned characters, or at the end of a function name to avoid creating
     13        duplicate parenthesis.
     14
    1152016-10-18  Joseph Pecoraro  <pecoraro@apple.com>
    216
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js

    r206015 r207481  
    538538            return [];
    539539
     540        // Don't complete in the middle of a property name.
     541        if (/^[a-z]/i.test(suffix))
     542            return [];
     543
    540544        var token = mainToken;
    541545        var lineNumber = this._lineNumber;
     
    562566
    563567            // If there is a suffix and it isn't a semicolon, then we should use a space since
    564             // the user is editing in the middle.
    565             this._implicitSuffix = suffix && suffix !== ";" ? " " : (this._noEndingSemicolon ? "" : ";");
     568            // the user is editing in the middle. Likewise if the suffix starts with an open
     569            // paren we are changing a function name so don't add a suffix.
     570            this._implicitSuffix = " ";
     571            if (suffix === ";")
     572                this._implicitSuffix = this._noEndingSemicolon ? "" : ";";
     573            else if (suffix.startsWith("("))
     574                this._implicitSuffix = "";
    566575
    567576            // Don't use an implicit suffix if it would be the same as the existing suffix.
     
    569578                this._implicitSuffix = "";
    570579
    571             return WebInspector.CSSKeywordCompletions.forProperty(propertyName).startsWith(this._prefix);
     580            let completions = WebInspector.CSSKeywordCompletions.forProperty(propertyName).startsWith(this._prefix);
     581
     582            if (suffix.startsWith("("))
     583                completions = completions.map((x) => x.replace(/\(\)$/, ""));
     584
     585            return completions;
    572586        }
    573587
Note: See TracChangeset for help on using the changeset viewer.