Title: [193045] branches/safari-601-branch/Source/WebInspectorUI

Diff

Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193044 => 193045)


--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 18:34:49 UTC (rev 193044)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 18:34:54 UTC (rev 193045)
@@ -1,5 +1,26 @@
 2015-12-01  Timothy Hatcher  <[email protected]>
 
+        Merge r187708. rdar://problem/23221163
+
+    2015-07-31  Devin Rousso  <[email protected]>
+
+            Web Inspector: Autocomplete: Undo (Cmd+Z) doesn't work as expected
+            https://bugs.webkit.org/show_bug.cgi?id=147316
+
+            Reviewed by Timothy Hatcher.
+
+            Instead of replacing the text for a completion, which messes up the undo history, add
+            a unique marker that contains the remaining text for the current completion.
+
+            * UserInterface/Controllers/CodeMirrorCompletionController.js:
+            (WebInspector.CodeMirrorCompletionController.prototype._createCompletionHintMarker):
+            (WebInspector.CodeMirrorCompletionController.prototype._applyCompletionHint.update):
+            (WebInspector.CodeMirrorCompletionController.prototype._applyCompletionHint):
+            (WebInspector.CodeMirrorCompletionController.prototype._removeCompletionHint.update):
+            (WebInspector.CodeMirrorCompletionController.prototype._removeCompletionHint):
+
+2015-12-01  Timothy Hatcher  <[email protected]>
+
         Merge r187700. rdar://problem/23221163
 
     2015-07-31  Devin Rousso  <[email protected]>

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (193044 => 193045)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2015-12-03 18:34:49 UTC (rev 193044)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2015-12-03 18:34:54 UTC (rev 193045)
@@ -245,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);
@@ -262,14 +271,11 @@
             var from = {line: this._lineNumber, ch: this._startOffset};
             var cursor = {line: this._lineNumber, ch: this._endOffset};
             var to = {line: this._lineNumber, ch: this._startOffset + replacementText.length};
+            var currentText = this._codeMirror.getRange(from, cursor);
 
-            this._codeMirror.replaceRange(replacementText, from, cursor, WebInspector.CodeMirrorCompletionController.CompletionOrigin);
-            this._removeLastChangeFromHistory();
-
-            this._codeMirror.setCursor(cursor);
-
+            this._createCompletionHintMarker(cursor, replacementText.replace(currentText, ""));
             if (cursor.ch !== to.ch)
-                this._completionHintMarker = this._codeMirror.markText(cursor, to, {className: WebInspector.CodeMirrorCompletionController.CompletionHintStyleClassName});
+                this._codeMirror.markText(cursor, to, {className: WebInspector.CodeMirrorCompletionController.CompletionHintStyleClassName});
         }
 
         this._ignoreChange = true;
@@ -339,13 +345,9 @@
         function update()
         {
             var range = this._completionHintMarker.find();
-            if (range) {
+            if (range)
                 this._completionHintMarker.clear();
 
-                this._codeMirror.replaceRange("", range.from, range.to, WebInspector.CodeMirrorCompletionController.DeleteCompletionOrigin);
-                this._removeLastChangeFromHistory();
-            }
-
             this._completionHintMarker = null;
 
             if (dontRestorePrefix)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to