Title: [191539] trunk/Source/WebInspectorUI
Revision
191539
Author
[email protected]
Date
2015-10-24 17:51:08 -0700 (Sat, 24 Oct 2015)

Log Message

Unreviewed, rolling out r191419.
https://bugs.webkit.org/show_bug.cgi?id=150537

Reverted changeset:

"Web Inspector: Autocompletion previews in the CSS sidebar do not apply"
https://bugs.webkit.org/show_bug.cgi?id=147720
http://trac.webkit.org/changeset/191419

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (191538 => 191539)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-10-24 23:36:19 UTC (rev 191538)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-10-25 00:51:08 UTC (rev 191539)
@@ -1,3 +1,14 @@
+2015-10-24  Nikita Vasilyev  <[email protected]>
+
+        Unreviewed, rolling out r191419.
+        https://bugs.webkit.org/show_bug.cgi?id=150537
+
+        Reverted changeset:
+
+        "Web Inspector: Autocompletion previews in the CSS sidebar do not apply"
+        https://bugs.webkit.org/show_bug.cgi?id=147720
+        http://trac.webkit.org/changeset/191419
+
 2015-10-23  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Remove unused ScrollLayer Timeline EventType

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (191538 => 191539)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2015-10-24 23:36:19 UTC (rev 191538)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2015-10-25 00:51:08 UTC (rev 191539)
@@ -58,14 +58,12 @@
             "Cmd-Y": this._handleHideKey.bind(this)
         };
 
-        this._handleBeforeChangeListener = this._handleBeforeChange.bind(this);
         this._handleChangeListener = this._handleChange.bind(this);
         this._handleCursorActivityListener = this._handleCursorActivity.bind(this);
         this._handleHideActionListener = this._handleHideAction.bind(this);
 
         this._codeMirror.addKeyMap(this._keyMap);
 
-        this._codeMirror.on("beforeChange", this._handleBeforeChangeListener);
         this._codeMirror.on("change", this._handleChangeListener);
         this._codeMirror.on("cursorActivity", this._handleCursorActivityListener);
         this._codeMirror.on("blur", this._handleHideActionListener);
@@ -172,7 +170,6 @@
     {
         this._codeMirror.removeKeyMap(this._keyMap);
 
-        this._codeMirror.off("beforeChange", this._handleBeforeChangeListener);
         this._codeMirror.off("change", this._handleChangeListener);
         this._codeMirror.off("cursorActivity", this._handleCursorActivityListener);
         this._codeMirror.off("blur", this._handleHideActionListener);
@@ -248,6 +245,15 @@
         this._notifyCompletionsHiddenIfNeededTimeout = setTimeout(notify.bind(this), WebInspector.CodeMirrorCompletionController.CompletionsHiddenDelay);
     }
 
+    _createCompletionHintMarker(position, text)
+    {
+        var container = document.createElement("span");
+        container.classList.add(WebInspector.CodeMirrorCompletionController.CompletionHintStyleClassName);
+        container.textContent = text;
+
+        this._completionHintMarker = this._codeMirror.setUniqueBookmark(position, {widget: container, insertLeft: true});
+    }
+
     _applyCompletionHint(completionText)
     {
         console.assert(completionText);
@@ -260,17 +266,13 @@
 
             this._removeCompletionHint(true, true);
 
-            let replacementText = this._currentReplacementText;
+            var replacementText = this._currentReplacementText;
 
-            let from = {line: this._lineNumber, ch: this._startOffset};
-            let cursor = {line: this._lineNumber, ch: this._endOffset};
-            let to = {line: this._lineNumber, ch: this._startOffset + replacementText.length};
+            var from = {line: this._lineNumber, ch: this._startOffset};
+            var cursor = {line: this._lineNumber, ch: this._endOffset};
+            var currentText = this._codeMirror.getRange(from, cursor);
 
-            this._codeMirror.replaceRange(replacementText, from, cursor, WebInspector.CodeMirrorCompletionController.CompletionOrigin);
-
-            this._codeMirror.setCursor(cursor);
-            if (cursor.ch !== to.ch)
-                this._completionHintMarker = this._codeMirror.markText(cursor, to, {className: WebInspector.CodeMirrorCompletionController.CompletionHintStyleClassName});
+            this._createCompletionHintMarker(cursor, replacementText.replace(currentText, ""));
         }
 
         this._ignoreChange = true;
@@ -300,6 +302,8 @@
 
             this._codeMirror.replaceRange(replacementText, from, cursor, WebInspector.CodeMirrorCompletionController.CompletionOrigin);
 
+            // Don't call _removeLastChangeFromHistory here to allow the committed completion to be undone.
+
             this._codeMirror.setCursor(to);
 
             this.hideCompletions();
@@ -335,16 +339,22 @@
 
         this._notifyCompletionsHiddenSoon();
 
-        function update()
+        function clearMarker(marker)
         {
-            this._codeMirror.undo();
+            if (!marker)
+                return;
 
-            let range = this._completionHintMarker.find();
+            var range = marker.find();
             if (range)
-                this._completionHintMarker.clear();
+                marker.clear();
 
-            this._completionHintMarker = null;
+            return null;
+        }
 
+        function update()
+        {
+            this._completionHintMarker = clearMarker(this._completionHintMarker);
+
             if (dontRestorePrefix)
                 return;
 
@@ -352,8 +362,8 @@
             console.assert(!isNaN(this._endOffset));
             console.assert(!isNaN(this._lineNumber));
 
-            let from = {line: this._lineNumber, ch: this._startOffset};
-            let to = {line: this._lineNumber, ch: this._endOffset};
+            var from = {line: this._lineNumber, ch: this._startOffset};
+            var to = {line: this._lineNumber, ch: this._endOffset};
 
             this._codeMirror.replaceRange(this._prefix, from, to, WebInspector.CodeMirrorCompletionController.DeleteCompletionOrigin);
             this._removeLastChangeFromHistory();
@@ -776,17 +786,6 @@
         this._applyCompletionHint(this._currentCompletion);
     }
 
-    _handleBeforeChange(codeMirror, change)
-    {
-        if (this.isCompletionChange(change))
-            return;
-
-        this._ignoreNextCursorActivity = true;
-
-        if (this.isShowingCompletions())
-            this.hideCompletions();
-    }
-
     _handleChange(codeMirror, change)
     {
         if (this.isCompletionChange(change))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to