Skip to content

Commit d9c1503

Browse files
committed
Fixed displaying of tabs in diffs.
1 parent d692bce commit d9c1503

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
**If you get an error right after updating just close all Brackets instances and start again. We are aware of this problem.**
44

5+
## 0.14.24 (14/04/2015)
6+
* Fixed displaying of tabs in diffs.
7+
58
## 0.14.23 (10/04/2015)
69
* Fixed previous fix for initial commit diff by [Marcel Gerber](https://github.com/MarcelGerber)
710

src/Utils.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ define(function (require, exports, module) {
4545
function formatDiff(diff) {
4646
var DIFF_MAX_LENGTH = 2000;
4747

48-
var tabSize = Preferences.getGlobal("tabSize"),
48+
var tabReplace = "",
4949
verbose = Preferences.get("useVerboseDiff"),
5050
numLineOld = 0,
5151
numLineNew = 0,
5252
lastStatus = 0,
5353
diffData = [];
5454

55+
var i = Preferences.getGlobal("tabSize");
56+
while (i--) {
57+
tabReplace += " ";
58+
}
59+
5560
var LINE_STATUS = {
5661
HEADER: 0,
5762
UNCHANGED: 1,
@@ -166,7 +171,10 @@ define(function (require, exports, module) {
166171
// removes ZERO WIDTH NO-BREAK SPACE character (BOM)
167172
line = line.replace(/\uFEFF/g, "");
168173

169-
line = _.escape(line).replace(/\s/g, " ");
174+
line = _.escape(line)
175+
.replace(/\t/g, tabReplace)
176+
.replace(/\s/g, " ");
177+
170178
line = line.replace(/( )+$/g, function (trailingWhitespace) {
171179
return "<span class='trailingWhitespace'>" + trailingWhitespace + "</span>";
172180
});
@@ -176,8 +184,7 @@ define(function (require, exports, module) {
176184
"numLineOld": _numLineOld,
177185
"numLineNew": _numLineNew,
178186
"line": line,
179-
"lineClass": lineClass,
180-
"tabSize": tabSize
187+
"lineClass": lineClass
181188
});
182189
}
183190
}

templates/format-diff.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<tr class="diff-row {{lineClass}}">
99
<td class="row-num">{{numLineOld}}</td>
1010
<td class="row-num">{{numLineNew}}</td>
11-
<td><pre style="tab-size: {{tabSize}}">{{{line}}}</pre></td>
11+
<td><pre>{{{line}}}</pre></td>
1212
</tr>
1313
{{/lines}}
1414
<tr class="separator"></tr>

0 commit comments

Comments
 (0)