- Revision
- 112053
- Author
- [email protected]
- Date
- 2012-03-25 23:17:48 -0700 (Sun, 25 Mar 2012)
Log Message
Web Inspector: Indenting fully selected line should not indent the line next to it
https://bugs.webkit.org/show_bug.cgi?id=81758
Source/WebCore:
In the editor, you can select a whole line by moving caret at 0 column
position and pressing Shift + Arrow Down/Up. After that, pressing Tab
indents 2 lines: fully selected one and the line next to it. The patch
changes this behaviour to indent only fully selected line since that is
what pretty-match all the other code editors do.
Patch by Nikita Vasilyev <[email protected]> on 2012-03-25
Reviewed by Pavel Feldman.
Test: inspector/editor/indentation.html
* inspector/front-end/TextViewer.js:
(WebInspector.TextEditorMainPanel.prototype._indentLines):
Do not insert indent at the begging of the last line if a selection
ends on its 0 column.
(WebInspector.TextEditorMainPanel.prototype._unindentLines):
Do not remove indent at the begging of the last line if a selection
ends on its 0 column.
LayoutTests:
Patch by Nikita Vasilyev <[email protected]> on 2012-03-25
Reviewed by Pavel Feldman.
* inspector/editor/indentation-expected.txt: Added.
* inspector/editor/indentation.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (112052 => 112053)
--- trunk/LayoutTests/ChangeLog 2012-03-26 06:12:36 UTC (rev 112052)
+++ trunk/LayoutTests/ChangeLog 2012-03-26 06:17:48 UTC (rev 112053)
@@ -1,3 +1,13 @@
+2012-03-25 Nikita Vasilyev <[email protected]>
+
+ Web Inspector: Indenting fully selected line should not indent the line next to it
+ https://bugs.webkit.org/show_bug.cgi?id=81758
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/editor/indentation-expected.txt: Added.
+ * inspector/editor/indentation.html: Added.
+
2012-03-25 Csaba Osztrogonác <[email protected]>
[Qt] Unreviewed morning gardening after r112023.
Added: trunk/LayoutTests/inspector/editor/indentation-expected.txt (0 => 112053)
--- trunk/LayoutTests/inspector/editor/indentation-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/editor/indentation-expected.txt 2012-03-26 06:17:48 UTC (rev 112053)
@@ -0,0 +1,27 @@
+This test checks code indentation and unindentation of several lines of code.
+
+After indenting first fully selected line
+ /*
+ * a comment
+ */
+Selection 0,0 1,0
+
+After indenting first partially selected line
+ /*
+ * a comment
+ */
+Selection 0,9 1,0
+
+After unindenting two fully selected lines
+ /*
+* a comment
+ */
+Selection 0,0 2,0
+
+After unindenting three partially selected lines
+/*
+* a comment
+*/
+Selection 0,0 2,2
+
+
Added: trunk/LayoutTests/inspector/editor/indentation.html (0 => 112053)
--- trunk/LayoutTests/inspector/editor/indentation.html (rev 0)
+++ trunk/LayoutTests/inspector/editor/indentation.html 2012-03-26 06:17:48 UTC (rev 112053)
@@ -0,0 +1,47 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function test()
+{
+ var src = "" +
+ " * a comment\n" +
+ " */";
+
+ var model = new WebInspector.TextEditorModel();
+ model.setText(null, src);
+ function noop() {}
+ var textEditorMainPanel = new WebInspector.TextEditorMainPanel(model, '', noop, noop, noop, noop);
+
+ var selection;
+ function dumpTextModel(msg)
+ {
+ InspectorTest.addResult(msg);
+ InspectorTest.addResult(model.text);
+ InspectorTest.addResult('Selection ' + selection.startLine + ',' + selection.startColumn + ' ' + selection.endLine + ',' + selection.endColumn + '\n');
+ }
+
+ selection = textEditorMainPanel._indentLines(new WebInspector.TextRange(0, 0, 1, 0));
+ dumpTextModel("After indenting first fully selected line");
+
+ selection = textEditorMainPanel._indentLines(new WebInspector.TextRange(0, 5, 1, 0));
+ dumpTextModel("After indenting first partially selected line");
+
+ selection = textEditorMainPanel._unindentLines(new WebInspector.TextRange(0, 0, 2, 0));
+ dumpTextModel("After unindenting two fully selected lines");
+
+ selection = textEditorMainPanel._unindentLines(new WebInspector.TextRange(0, 0, 2, 3));
+ dumpTextModel("After unindenting three partially selected lines");
+
+ InspectorTest.completeTest();
+}
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+This test checks code indentation and unindentation of several lines of code.
+</p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (112052 => 112053)
--- trunk/Source/WebCore/ChangeLog 2012-03-26 06:12:36 UTC (rev 112052)
+++ trunk/Source/WebCore/ChangeLog 2012-03-26 06:17:48 UTC (rev 112053)
@@ -1,3 +1,26 @@
+2012-03-25 Nikita Vasilyev <[email protected]>
+
+ Web Inspector: Indenting fully selected line should not indent the line next to it
+ https://bugs.webkit.org/show_bug.cgi?id=81758
+
+ In the editor, you can select a whole line by moving caret at 0 column
+ position and pressing Shift + Arrow Down/Up. After that, pressing Tab
+ indents 2 lines: fully selected one and the line next to it. The patch
+ changes this behaviour to indent only fully selected line since that is
+ what pretty-match all the other code editors do.
+
+ Reviewed by Pavel Feldman.
+
+ Test: inspector/editor/indentation.html
+
+ * inspector/front-end/TextViewer.js:
+ (WebInspector.TextEditorMainPanel.prototype._indentLines):
+ Do not insert indent at the begging of the last line if a selection
+ ends on its 0 column.
+ (WebInspector.TextEditorMainPanel.prototype._unindentLines):
+ Do not remove indent at the begging of the last line if a selection
+ ends on its 0 column.
+
2012-03-25 Abhishek Arya <[email protected]>
Crash in ContainerNode::resumePostAttachCallbacks.
Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (112052 => 112053)
--- trunk/Source/WebCore/inspector/front-end/TextViewer.js 2012-03-26 06:12:36 UTC (rev 112052)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js 2012-03-26 06:17:48 UTC (rev 112053)
@@ -1126,12 +1126,21 @@
if (this._lastEditedRange)
this._textModel.markUndoableState();
- for (var lineNumber = range.startLine; lineNumber <= range.endLine; lineNumber++)
+ var newRange = range.clone();
+
+ // Do not change a selection start position when it is at the beginning of a line
+ if (range.startColumn)
+ newRange.startColumn += indent.length;
+
+ var indentEndLine = range.endLine;
+ if (range.endColumn)
+ newRange.endColumn += indent.length;
+ else
+ indentEndLine--;
+
+ for (var lineNumber = range.startLine; lineNumber <= indentEndLine; lineNumber++)
this._textModel.setText(new WebInspector.TextRange(lineNumber, 0, lineNumber, 0), indent);
- var newRange = range.clone();
- newRange.startColumn += indent.length;
- newRange.endColumn += indent.length;
this._lastEditedRange = newRange;
return newRange;
@@ -1147,7 +1156,11 @@
var lineIndentRegex = new RegExp("^ {1," + indentLength + "}");
var newRange = range.clone();
- for (var lineNumber = range.startLine; lineNumber <= range.endLine; lineNumber++) {
+ var indentEndLine = range.endLine;
+ if (!range.endColumn)
+ indentEndLine--;
+
+ for (var lineNumber = range.startLine; lineNumber <= indentEndLine; lineNumber++) {
var line = this._textModel.line(lineNumber);
var firstCharacter = line.charAt(0);
var lineIndentLength;