Title: [142886] trunk
Revision
142886
Author
[email protected]
Date
2013-02-14 09:38:42 -0800 (Thu, 14 Feb 2013)

Log Message

Web Inspector: [Regression] When several consecutive characters are typed each of them is marked as undoable state.
https://bugs.webkit.org/show_bug.cgi?id=109823

Reviewed by Pavel Feldman.

Source/WebCore:

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

LayoutTests:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142885 => 142886)


--- trunk/LayoutTests/ChangeLog	2013-02-14 17:23:48 UTC (rev 142885)
+++ trunk/LayoutTests/ChangeLog	2013-02-14 17:38:42 UTC (rev 142886)
@@ -1,3 +1,13 @@
+2013-02-14  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: [Regression] When several consecutive characters are typed each of them is marked as undoable state.
+        https://bugs.webkit.org/show_bug.cgi?id=109823
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/editor/text-editor-undo-redo-expected.txt:
+        * inspector/editor/text-editor-undo-redo.html:
+
 2013-02-14  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r142820.

Modified: trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt (142885 => 142886)


--- trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt	2013-02-14 17:23:48 UTC (rev 142885)
+++ trunk/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt	2013-02-14 17:38:42 UTC (rev 142886)
@@ -9,17 +9,73 @@
 
 Text after edit:
 1
-	2
+	|2
 3
 
 Text after undo:
 1
-2
+|2
 3
 
 Text after redo:
 1
-	2
+>	<2
 3
 
 
+Running: testConsecutiveCharactersAndNewLines
+Text before edit:
+function foo()
+{
+
+}
+
+Text after edit:
+function foo()
+{
+    bar();
+    baz();
+    foo();|
+}
+
+Text after first undo:
+function foo()
+{
+    bar();
+    baz();|
+}
+
+Text after second undo:
+function foo()
+{
+    bar();|
+}
+
+Text after third undo:
+function foo()
+{
+|
+}
+
+Text after first redo:
+function foo()
+{
+    bar()>;<
+}
+
+Text after second redo:
+function foo()
+{
+    bar();
+    baz()>;<
+}
+
+Text after third redo:
+function foo()
+{
+    bar();
+    baz();
+    foo()>;<
+}
+
+

Modified: trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html (142885 => 142886)


--- trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html	2013-02-14 17:23:48 UTC (rev 142885)
+++ trunk/LayoutTests/inspector/editor/text-editor-undo-redo.html	2013-02-14 17:38:42 UTC (rev 142886)
@@ -2,33 +2,82 @@
 <head>
 <script src=""
 <script>
-
 function test()
 {
+    function textWithSelection(text, selection)
+    {
+        if (!selection)
+            return text;
+
+        function lineWithCursor(line, column, cursorChar)
+        {
+            return line.substring(0, column) + cursorChar + line.substring(column);
+        }
+
+        var lines = text.split("\n");
+        selection = selection.normalize();
+        var endCursorChar = selection.isEmpty() ? "|" : "<";
+        lines[selection.endLine] = lineWithCursor(lines[selection.endLine], selection.endColumn, endCursorChar);
+        if (!selection.isEmpty()) {
+            lines[selection.startLine] = lineWithCursor(lines[selection.startLine], selection.startColumn, ">");
+        }
+        return lines.join("\n");
+    }
+
+    function dumpTextModel(prefix, textModel, range)
+    {
+        var text = textWithSelection(textModel.text(), range);
+        InspectorTest.addResult(prefix + text);
+    }
+
+    function typeText(textModel, startRange, text)
+    {
+        var range = startRange;
+        for (var i = 0; i < text.length; ++i)
+            range = textModel.editRange(range, text[i]).collapseToEnd();
+        return range;
+    }
     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());
+            dumpTextModel("Text before edit:\n", textModel);
+            var range = typeText(textModel, new WebInspector.TextRange(1, 0, 1, 0), "\t")
+            dumpTextModel("Text after edit:\n", textModel, range);
+            range = textModel.undo();
+            dumpTextModel("Text after undo:\n", textModel, range);
+            range = textModel.redo();
+            dumpTextModel("Text after redo:\n", textModel, range);
             next();
+        },
+
+        function testConsecutiveCharactersAndNewLines(next)
+        {
+            var textModel = new WebInspector.TextEditorModel();
+            textModel.setText("function foo()\n{\n\n}\n");
+            dumpTextModel("Text before edit:\n", textModel);
+            var range = typeText(textModel, new WebInspector.TextRange(2, 0, 2, 0), "    bar();\n    baz();\n    foo();");
+            dumpTextModel("Text after edit:\n", textModel, range);
+            range = textModel.undo();
+            dumpTextModel("Text after first undo:\n", textModel, range);
+            range = textModel.undo();
+            dumpTextModel("Text after second undo:\n", textModel, range);
+            range = textModel.undo();
+            dumpTextModel("Text after third undo:\n", textModel, range);
+            range = textModel.redo();
+            dumpTextModel("Text after first redo:\n", textModel, range);
+            range = textModel.redo();
+            dumpTextModel("Text after second redo:\n", textModel, range);
+            range = textModel.redo();
+            dumpTextModel("Text after third redo:\n", textModel, range);
+            next();
         }
     ]);
 }
-
 </script>
 </head>
-
 <body _onload_="runTest()">
-<p>
-Tests undo/redo operations in the editor model.
-</p>
-
+<p>Tests undo/redo operations in the editor model.</p>
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (142885 => 142886)


--- trunk/Source/WebCore/ChangeLog	2013-02-14 17:23:48 UTC (rev 142885)
+++ trunk/Source/WebCore/ChangeLog	2013-02-14 17:38:42 UTC (rev 142886)
@@ -1,3 +1,13 @@
+2013-02-14  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: [Regression] When several consecutive characters are typed each of them is marked as undoable state.
+        https://bugs.webkit.org/show_bug.cgi?id=109823
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/TextEditorModel.js:
+        (WebInspector.TextEditorModel.endsWithBracketRegex.):
+
 2013-02-14  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r142820.

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


--- trunk/Source/WebCore/inspector/front-end/TextEditorModel.js	2013-02-14 17:23:48 UTC (rev 142885)
+++ trunk/Source/WebCore/inspector/front-end/TextEditorModel.js	2013-02-14 17:38:42 UTC (rev 142886)
@@ -267,13 +267,12 @@
     _innerEditRange: function(range, text)
     {
         var originalText = this.copyRange(range);
-        this._lastEditedRange = range;
         var newRange = range;
         if (text !== originalText) {
             newRange = this._innerSetText(range, text);
             this._pushUndoableCommand(newRange, originalText);
         }
-
+        this._lastEditedRange = newRange;
         this.dispatchEventToListeners(WebInspector.TextEditorModel.Events.TextChanged, { oldRange: range, newRange: newRange, editRange: true });
         return newRange;
     },
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to