Changeset 54415 in webkit


Ignore:
Timestamp:
Feb 5, 2010 2:50:42 AM (14 years ago)
Author:
eric@webkit.org
Message:

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):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54413 r54415  
     12010-02-05  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: Tab width for javascript source is 8, should be 4
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=31248
     8
     9        * inspector/front-end/SourceFrame.js:
     10        (WebInspector.SourceFrame):
     11        * inspector/front-end/TextEditorModel.js:
     12        (WebInspector.TextEditorModel.prototype.set replaceTabsWithSpaces):
     13        (WebInspector.TextEditorModel.prototype._innerSetText):
     14        (WebInspector.TextEditorModel.prototype._replaceTabsIfNeeded):
     15
    1162010-02-05  Tony Chang  <tony@chromium.org>
    217
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r54231 r54415  
    3434
    3535    this._textModel = new WebInspector.TextEditorModel();
     36    this._textModel.replaceTabsWithSpaces = true;
    3637
    3738    this._messages = [];
  • trunk/WebCore/inspector/front-end/TextEditorModel.js

    r54052 r54415  
    9898    },
    9999
     100    set replaceTabsWithSpaces(replaceTabsWithSpaces)
     101    {
     102        this._replaceTabsWithSpaces = replaceTabsWithSpaces;
     103    },
     104
    100105    _innerSetText: function(range, text)
    101106    {
     
    105110
    106111        var newLines = text.split("\n");
     112        this._replaceTabsIfNeeded(newLines);
     113
    107114        var prefix = this._lines[range.startLine].substring(0, range.startColumn);
    108115        var prefixArguments = this._arguments
     
    123130        return new WebInspector.TextRange(range.startLine, range.startColumn,
    124131                                          range.startLine + newLines.length - 1, postCaret);
     132    },
     133
     134    _replaceTabsIfNeeded: function(lines)
     135    {
     136        if (!this._replaceTabsWithSpaces)
     137            return;
     138        var spaces = [ "    ", "   ", "  ", " "];
     139        for (var i = 0; i < lines.length; ++i) {
     140            var line = lines[i];
     141            var index = line.indexOf("\t");
     142            while (index !== -1) {
     143                line = line.substring(0, index) + spaces[index % 4] + line.substring(index + 1);
     144                index = line.indexOf("\t", index + 1);
     145            }
     146            lines[i] = line;
     147        }
    125148    },
    126149
Note: See TracChangeset for help on using the changeset viewer.