fix tab detection
This commit is contained in:
parent
88aed65212
commit
ba93cc6dfa
1 changed files with 2 additions and 6 deletions
|
|
@ -46,7 +46,6 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
if (!/^\s*[^*+\-\s]/.test(line))
|
||||
continue;
|
||||
|
||||
var tabs = line.match(/^\t*/)[0].length;
|
||||
if (line[0] == "\t")
|
||||
tabIndents++;
|
||||
|
||||
|
|
@ -65,9 +64,6 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
line = lines[i++];
|
||||
}
|
||||
|
||||
if (!stats.length)
|
||||
return;
|
||||
|
||||
function getScore(indent) {
|
||||
var score = 0;
|
||||
for (var i = indent; i < stats.length; i += indent)
|
||||
|
|
@ -82,7 +78,7 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
for (var i = 1; i < 12; i++) {
|
||||
if (i == 1) {
|
||||
spaceIndents = getScore(i);
|
||||
var score = 1;
|
||||
var score = stats.length && 1;
|
||||
} else
|
||||
var score = getScore(i) / spaceIndents;
|
||||
|
||||
|
|
@ -99,7 +95,7 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
if (tabIndents > spaceIndents + 1)
|
||||
return {ch: "\t", length: tabLength};
|
||||
|
||||
if (spaceIndents + 1 > tabIndents)
|
||||
if (spaceIndents > tabIndents + 1)
|
||||
return {ch: " ", length: tabLength};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue