Title: [112674] trunk
Revision
112674
Author
pfeld...@chromium.org
Date
2012-03-30 09:24:35 -0700 (Fri, 30 Mar 2012)

Log Message

Web Inspector: undo-ing edit that consists of a Tab does not work.
https://bugs.webkit.org/show_bug.cgi?id=82733

Reviewed by Vsevolod Vlasov.

Source/WebCore:

We should never modify the range returned by the edit operation manually.
And we should clone ranges that get into the model so that subsequent edits
don't mutate them.

Drive-by: restore selection after undo via selecting all the text that undo
operation produced.

Test: inspector/editor/text-editor-undo-redo.html

* inspector/front-end/TextEditorModel.js:
(WebInspector.TextEditorModel.endsWithBracketRegex.):
* inspector/front-end/TextViewer.js:

LayoutTests:

* inspector/editor/text-editor-undo-redo-expected.txt: Added.
* inspector/editor/text-editor-undo-redo.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112673 => 112674)


--- trunk/LayoutTests/ChangeLog	2012-03-30 16:23:45 UTC (rev 112673)
+++ trunk/LayoutTests/ChangeLog	2012-03-30 16:24:35 UTC (rev 112674)
@@ -1,3 +1,13 @@
+2012-03-30  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: undo-ing edit that consists of a Tab does not work.
+        https://bugs.webkit.org/show_bug.cgi?id=82733
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/editor/text-editor-undo-redo-expected.txt: Added.
+        * inspector/editor/text-editor-undo-redo.html: Added.
+
 2012-03-30  Csaba Osztrogonác  <o...@webkit.org>
 
         Add new renderer for circles and ellipses

Added: trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt (0 => 112674)


--- trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt	2012-03-30 16:24:35 UTC (rev 112674)
@@ -0,0 +1,25 @@
+Tests undo/redo operations in the editor model.
+
+
+Running: testUndoRedoTab
+Text before edit:
+1
+2
+3
+
+Text after edit:
+1
+	2
+3
+
+Text after undo:
+1
+2
+3
+
+Text after redo:
+1
+	2
+3
+
+
Property changes on: trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html (0 => 112674)


--- trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html	2012-03-30 16:24:35 UTC (rev 112674)
@@ -0,0 +1,34 @@
+<html>
+<head>
+<script src=""
+<script>
+
+function test()
+{
+    InspectorTest.runTestSuite([
+        function testUndoRedoTab(next)
+        {
+            var textModel = new WebInspector.TextEditorModel();
+            textModel.setText("1\n2\n3\n");
+            InspectorTest.addResult("Text before edit:\n" + textModel.text);
+            textModel.editRange(new WebInspector.TextRange(1, 0, 1, 0), "\t");
+            InspectorTest.addResult("Text after edit:\n" + textModel.text);
+            textModel.undo();
+            InspectorTest.addResult("Text after undo:\n" + textModel.text);
+            textModel.redo();
+            InspectorTest.addResult("Text after redo:\n" + textModel.text);
+            next();
+        }
+    ]);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests undo/redo operations in the editor model.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (112673 => 112674)


--- trunk/Source/WebCore/ChangeLog	2012-03-30 16:23:45 UTC (rev 112673)
+++ trunk/Source/WebCore/ChangeLog	2012-03-30 16:24:35 UTC (rev 112674)
@@ -1,3 +1,23 @@
+2012-03-30  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: undo-ing edit that consists of a Tab does not work.
+        https://bugs.webkit.org/show_bug.cgi?id=82733
+
+        Reviewed by Vsevolod Vlasov.
+
+        We should never modify the range returned by the edit operation manually.
+        And we should clone ranges that get into the model so that subsequent edits
+        don't mutate them.
+
+        Drive-by: restore selection after undo via selecting all the text that undo
+        operation produced.
+
+        Test: inspector/editor/text-editor-undo-redo.html
+
+        * inspector/front-end/TextEditorModel.js:
+        (WebInspector.TextEditorModel.endsWithBracketRegex.):
+        * inspector/front-end/TextViewer.js:
+
 2012-03-30  Malcolm MacLeod  <malcolm.macl...@tshwanedje.com>
 
         [wx] Implement Gradient and ImageBuffer support.

Modified: trunk/Source/WebCore/inspector/front-end/TextEditorModel.js (112673 => 112674)


--- trunk/Source/WebCore/inspector/front-end/TextEditorModel.js	2012-03-30 16:23:45 UTC (rev 112673)
+++ trunk/Source/WebCore/inspector/front-end/TextEditorModel.js	2012-03-30 16:24:35 UTC (rev 112674)
@@ -386,7 +386,7 @@
      */
     _pushUndoableCommand: function(newRange, originalText)
     {
-        var command = new WebInspector.TextEditorCommand(newRange, originalText);
+        var command = new WebInspector.TextEditorCommand(newRange.clone(), originalText);
         if (this._inUndo)
             this._redoStack.push(command);
         else {

Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (112673 => 112674)


--- trunk/Source/WebCore/inspector/front-end/TextViewer.js	2012-03-30 16:23:45 UTC (rev 112673)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js	2012-03-30 16:24:35 UTC (rev 112674)
@@ -1100,7 +1100,7 @@
 
         // Restore location post-repaint.
         if (range)
-            this._setCaretLocation(range.endLine, range.endColumn, true);
+            this._restoreSelection(range, true);
 
         return true;
     },
@@ -1120,19 +1120,20 @@
         this._enterTextChangeMode();
 
         var newRange;
+        var rangeWasEmpty = range.isEmpty();
         if (shiftKey)
             newRange = this._unindentLines(range);
         else {
-            if (range.isEmpty()) {
+            if (rangeWasEmpty)
                 newRange = this._editRange(range, WebInspector.settings.textEditorIndent.get());
-                newRange.startColumn = newRange.endColumn;
-            } else
+            else
                 newRange = this._indentLines(range);
-
         }
 
         this._exitTextChangeMode(range, newRange);
         this.endUpdates();
+        if (rangeWasEmpty)
+            newRange.startColumn = newRange.endColumn;
         this._restoreSelection(newRange, true);
         return true;
     },
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to