Skip to content

Commit 1b6b969

Browse files
committed
fixes neekey/ps#7 - first field always starts at 0
1 parent 74c0864 commit 1b6b969

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ module.exports.parse = function( output ){
3434
if( index == 0 ){
3535
var fields = line.split( /\s+/ );
3636
// 保存各字段的开始和结束位置
37+
var fieldIndex = 0;
3738
fields.forEach(function( field ){
3839

3940
if( field ){
4041
var info = titleInfo[ field ] = {};
4142
// 记录字段值的开始和结束
42-
info.titleBegin = line.indexOf( field );
43+
if ( fieldIndex == 0 ){
44+
info.titleBegin = 0;
45+
}else{
46+
info.titleBegin = line.indexOf( field );
47+
}
4348
info.titleEnd = info.titleBegin + field.length - 1;
49+
fieldIndex++;
4450
}
4551
});
4652
}

0 commit comments

Comments
 (0)