Commit 90e6d0c7 authored by eric@webkit.org's avatar eric@webkit.org

2010-02-05 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Timothy Hatcher.

        Web Inspector: Tab width for javascript source is 8, should be 4

        https://bugs.webkit.org/show_bug.cgi?id=31248

        * inspector/front-end/SourceFrame.js:
        (WebInspector.SourceFrame):
        * inspector/front-end/TextEditorModel.js:
        (WebInspector.TextEditorModel.prototype.set replaceTabsWithSpaces):
        (WebInspector.TextEditorModel.prototype._innerSetText):
        (WebInspector.TextEditorModel.prototype._replaceTabsIfNeeded):

git-svn-id: svn://svn.chromium.org/blink/trunk@54415 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e543d4f2
2010-02-05 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: Tab width for javascript source is 8, should be 4
https://bugs.webkit.org/show_bug.cgi?id=31248
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
* inspector/front-end/TextEditorModel.js:
(WebInspector.TextEditorModel.prototype.set replaceTabsWithSpaces):
(WebInspector.TextEditorModel.prototype._innerSetText):
(WebInspector.TextEditorModel.prototype._replaceTabsIfNeeded):
2010-02-05 Tony Chang <tony@chromium.org>
Reviewed by Eric Seidel.
......
......@@ -33,6 +33,7 @@ WebInspector.SourceFrame = function(parentElement, addBreakpointDelegate)
this._parentElement = parentElement;
this._textModel = new WebInspector.TextEditorModel();
this._textModel.replaceTabsWithSpaces = true;
this._messages = [];
this._rowMessages = {};
......
......@@ -97,6 +97,11 @@ WebInspector.TextEditorModel.prototype = {
return newRange;
},
set replaceTabsWithSpaces(replaceTabsWithSpaces)
{
this._replaceTabsWithSpaces = replaceTabsWithSpaces;
},
_innerSetText: function(range, text)
{
this._eraseRange(range);
......@@ -104,6 +109,8 @@ WebInspector.TextEditorModel.prototype = {
return new WebInspector.TextRange(range.startLine, range.startColumn, range.startLine, range.startColumn);
var newLines = text.split("\n");
this._replaceTabsIfNeeded(newLines);
var prefix = this._lines[range.startLine].substring(0, range.startColumn);
var prefixArguments = this._arguments
var suffix = this._lines[range.startLine].substring(range.startColumn);
......@@ -124,6 +131,22 @@ WebInspector.TextEditorModel.prototype = {
range.startLine + newLines.length - 1, postCaret);
},
_replaceTabsIfNeeded: function(lines)
{
if (!this._replaceTabsWithSpaces)
return;
var spaces = [ " ", " ", " ", " "];
for (var i = 0; i < lines.length; ++i) {
var line = lines[i];
var index = line.indexOf("\t");
while (index !== -1) {
line = line.substring(0, index) + spaces[index % 4] + line.substring(index + 1);
index = line.indexOf("\t", index + 1);
}
lines[i] = line;
}
},
_eraseRange: function(range)
{
if (range.isEmpty())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment