Changeset 186217 in webkit


Ignore:
Timestamp:
Jul 1, 2015 9:30:53 PM (9 years ago)
Author:
Devin Rousso
Message:

Web Inspector: When autocompleting, pressing tab twice shouldn't insert a tab character
https://bugs.webkit.org/show_bug.cgi?id=145885

Reviewed by Timothy Hatcher.

  • UserInterface/Controllers/CodeMirrorCompletionController.js:

(WebInspector.CodeMirrorCompletionController):
(WebInspector.CodeMirrorCompletionController.prototype.updateCompletions): Resolves the promise as having completions.
(WebInspector.CodeMirrorCompletionController.prototype.hideCompletions): Resolves the promise as not having completions.
(WebInspector.CodeMirrorCompletionController.prototype.completeAtCurrentPositionIfNeeded): Returns a WrappedPromise that allows
callers of this function to determine if the autocomplete had any values or was instead not shown.
(WebInspector.CodeMirrorCompletionController.prototype._resolveUpdatePromise):

  • UserInterface/Main.html: Added WrappedPromise class.
  • UserInterface/Models/WrappedPromise.js: Added WrappedPromise object to expose resolve and reject functions.
  • UserInterface/Views/ConsolePrompt.js:

(WebInspector.ConsolePrompt.prototype._handleTabKey): Attempts to find completions for current text. If there are none, beep.

Location:
trunk/Source/WebInspectorUI
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r186212 r186217  
     12015-07-01  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: When autocompleting, pressing tab twice shouldn't insert a tab character
     4        https://bugs.webkit.org/show_bug.cgi?id=145885
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Controllers/CodeMirrorCompletionController.js:
     9        (WebInspector.CodeMirrorCompletionController):
     10        (WebInspector.CodeMirrorCompletionController.prototype.updateCompletions): Resolves the promise as having completions.
     11        (WebInspector.CodeMirrorCompletionController.prototype.hideCompletions): Resolves the promise as not having completions.
     12        (WebInspector.CodeMirrorCompletionController.prototype.completeAtCurrentPositionIfNeeded): Returns a WrappedPromise that allows
     13        callers of this function to determine if the autocomplete had any values or was instead not shown.
     14        (WebInspector.CodeMirrorCompletionController.prototype._resolveUpdatePromise):
     15        * UserInterface/Main.html: Added WrappedPromise class.
     16        * UserInterface/Models/WrappedPromise.js: Added WrappedPromise object to expose resolve and reject functions.
     17        * UserInterface/Views/ConsolePrompt.js:
     18        (WebInspector.ConsolePrompt.prototype._handleTabKey): Attempts to find completions for current text.  If there are none, beep.
     19
    1202015-07-01  Devin Rousso  <drousso@apple.com>
    221
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js

    r185935 r186217  
    6969        this._codeMirror.on("blur", this._handleHideActionListener);
    7070        this._codeMirror.on("scroll", this._handleHideActionListener);
     71
     72        this._updatePromise = null;
    7173    }
    7274
     
    126128
    127129        this._applyCompletionHint(completions[index]);
     130
     131        this._resolveUpdatePromise(WebInspector.CodeMirrorCompletionController.UpdatePromise.CompletionsFound);
    128132    }
    129133
     
    159163        delete this._currentCompletion;
    160164        delete this._ignoreNextCursorActivity;
     165
     166        this._resolveUpdatePromise(WebInspector.CodeMirrorCompletionController.UpdatePromise.NoCompletionsFound);
    161167    }
    162168
     
    171177    }
    172178
     179    completeAtCurrentPositionIfNeeded(force)
     180    {
     181        this._resolveUpdatePromise(WebInspector.CodeMirrorCompletionController.UpdatePromise.Canceled);
     182
     183        var update = this._updatePromise = new WebInspector.WrappedPromise;
     184
     185        this._completeAtCurrentPosition(force);
     186
     187        return update.promise;
     188    }
     189
    173190    // Protected
    174191
     
    193210
    194211    // Private
     212
     213    _resolveUpdatePromise(message)
     214    {
     215        if (!this._updatePromise)
     216            return;
     217
     218        this._updatePromise.resolve(message);
     219        this._updatePromise = null;
     220    }
    195221
    196222    get _currentReplacementText()
     
    803829};
    804830
     831WebInspector.CodeMirrorCompletionController.UpdatePromise = {
     832    Canceled: "code-mirror-completion-controller-canceled",
     833    CompletionsFound: "code-mirror-completion-controller-completions-found",
     834    NoCompletionsFound: "code-mirror-completion-controller-no-completions-found"
     835};
     836
    805837WebInspector.CodeMirrorCompletionController.GenericStopCharactersRegex = /[\s=:;,]/;
    806838WebInspector.CodeMirrorCompletionController.DefaultStopCharactersRegexModeMap = {"css": /[\s:;,{}()]/, "javascript": /[\s=:;,!+\-*/%&|^~?<>.{}()[\]]/};
  • trunk/Source/WebInspectorUI/UserInterface/Main.html

    r185044 r186217  
    311311    <script src="Models/TypeSet.js"></script>
    312312    <script src="Models/UnitBezier.js"></script>
     313    <script src="Models/WrappedPromise.js"></script>
    313314
    314315    <script src="Views/ConsoleCommandView.js"></script>
  • trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js

    r184819 r186217  
    5252        "Enter": this._handleEnterKey.bind(this),
    5353        "Cmd-Enter": this._handleCommandEnterKey.bind(this),
     54        "Tab": this._handleTabKey.bind(this),
    5455        "Esc": this._handleEscapeKey.bind(this)
    5556    };
     
    164165
    165166    // Private
     167
     168    _handleTabKey: function(codeMirror)
     169    {
     170        this._completionController.completeAtCurrentPositionIfNeeded().then(function(result) {
     171            if (result === WebInspector.CodeMirrorCompletionController.UpdatePromise.NoCompletionsFound)
     172                InspectorFrontendHost.beep();
     173        });
     174    },
    166175
    167176    _handleEscapeKey: function(codeMirror)
Note: See TracChangeset for help on using the changeset viewer.