Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2f42dac1
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f42dac1
编写于
2月 14, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure ViewLineToken.endIndex is <= lineLength
上级
42dfb39f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
92 addition
and
9 deletion
+92
-9
src/vs/editor/browser/viewParts/minimap/minimap.ts
src/vs/editor/browser/viewParts/minimap/minimap.ts
+0
-3
src/vs/editor/common/core/viewLineToken.ts
src/vs/editor/common/core/viewLineToken.ts
+3
-2
src/vs/editor/test/common/core/lineTokens.test.ts
src/vs/editor/test/common/core/lineTokens.test.ts
+89
-4
未找到文件。
src/vs/editor/browser/viewParts/minimap/minimap.ts
浏览文件 @
2f42dac1
...
...
@@ -339,9 +339,6 @@ export class Minimap extends ViewPart {
// hit edge of minimap
return
;
}
// if (charIndex >= content.length) {
// console.log('SERIOUSLY');
// }
const
charCode
=
content
.
charCodeAt
(
charIndex
);
if
(
charCode
===
CharCode
.
Tab
)
{
...
...
src/vs/editor/common/core/viewLineToken.ts
浏览文件 @
2f42dac1
...
...
@@ -70,7 +70,8 @@ export class ViewLineTokenFactory {
}
public
static
sliceAndInflate
(
tokens
:
Uint32Array
,
startOffset
:
number
,
endOffset
:
number
,
deltaOffset
:
number
,
lineLength
:
number
):
ViewLineToken
[]
{
let
tokenIndex
=
this
.
findIndexInSegmentsArray
(
tokens
,
startOffset
);
const
tokenIndex
=
this
.
findIndexInSegmentsArray
(
tokens
,
startOffset
);
const
maxEndOffset
=
(
endOffset
-
startOffset
+
deltaOffset
);
let
result
:
ViewLineToken
[]
=
[],
resultLen
=
0
;
for
(
let
i
=
tokenIndex
,
len
=
(
tokens
.
length
>>>
1
);
i
<
len
;
i
++
)
{
...
...
@@ -81,7 +82,7 @@ export class ViewLineTokenFactory {
}
let
tokenEndOffset
=
(
i
+
1
<
len
?
tokens
[((
i
+
1
)
<<
1
)]
:
lineLength
);
let
newEndOffset
=
tokenEndOffset
-
startOffset
+
deltaOffset
;
let
newEndOffset
=
Math
.
min
(
maxEndOffset
,
tokenEndOffset
-
startOffset
+
deltaOffset
)
;
let
metadata
=
tokens
[(
i
<<
1
)
+
1
];
result
[
resultLen
++
]
=
new
ViewLineToken
(
newEndOffset
,
metadata
);
...
...
src/vs/editor/test/common/core/lineTokens.test.ts
浏览文件 @
2f42dac1
...
...
@@ -8,6 +8,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
LineTokens
}
from
'
vs/editor/common/core/lineTokens
'
;
import
{
MetadataConsts
}
from
'
vs/editor/common/modes
'
;
import
{
ViewLineToken
}
from
'
vs/editor/common/core/viewLineToken
'
;
suite
(
'
LineTokens
'
,
()
=>
{
...
...
@@ -200,8 +201,92 @@ suite('LineTokens', () => {
assert
.
equal
(
token
,
null
);
});
// test('inflate', () => {
// const lineTokens = createTestLineTokens();
// });
interface
ITestViewLineToken
{
endIndex
:
number
;
foreground
:
number
;
}
function
assertViewLineTokens
(
actual
:
ViewLineToken
[],
expected
:
ITestViewLineToken
[]):
void
{
assert
.
deepEqual
(
actual
.
map
(
token
=>
{
return
{
endIndex
:
token
.
endIndex
,
foreground
:
token
.
getForeground
()
};
}),
expected
);
}
test
(
'
inflate
'
,
()
=>
{
const
lineTokens
=
createTestLineTokens
();
assertViewLineTokens
(
lineTokens
.
inflate
(),
[
{
endIndex
:
6
,
foreground
:
1
},
{
endIndex
:
13
,
foreground
:
2
},
{
endIndex
:
18
,
foreground
:
3
},
{
endIndex
:
21
,
foreground
:
4
},
{
endIndex
:
23
,
foreground
:
5
},
{
endIndex
:
30
,
foreground
:
6
},
{
endIndex
:
33
,
foreground
:
7
},
]);
});
test
(
'
sliceAndInflate
'
,
()
=>
{
const
lineTokens
=
createTestLineTokens
();
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
0
,
33
,
0
),
[
{
endIndex
:
6
,
foreground
:
1
},
{
endIndex
:
13
,
foreground
:
2
},
{
endIndex
:
18
,
foreground
:
3
},
{
endIndex
:
21
,
foreground
:
4
},
{
endIndex
:
23
,
foreground
:
5
},
{
endIndex
:
30
,
foreground
:
6
},
{
endIndex
:
33
,
foreground
:
7
},
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
0
,
32
,
0
),
[
{
endIndex
:
6
,
foreground
:
1
},
{
endIndex
:
13
,
foreground
:
2
},
{
endIndex
:
18
,
foreground
:
3
},
{
endIndex
:
21
,
foreground
:
4
},
{
endIndex
:
23
,
foreground
:
5
},
{
endIndex
:
30
,
foreground
:
6
},
{
endIndex
:
32
,
foreground
:
7
},
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
0
,
30
,
0
),
[
{
endIndex
:
6
,
foreground
:
1
},
{
endIndex
:
13
,
foreground
:
2
},
{
endIndex
:
18
,
foreground
:
3
},
{
endIndex
:
21
,
foreground
:
4
},
{
endIndex
:
23
,
foreground
:
5
},
{
endIndex
:
30
,
foreground
:
6
}
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
0
,
30
,
1
),
[
{
endIndex
:
7
,
foreground
:
1
},
{
endIndex
:
14
,
foreground
:
2
},
{
endIndex
:
19
,
foreground
:
3
},
{
endIndex
:
22
,
foreground
:
4
},
{
endIndex
:
24
,
foreground
:
5
},
{
endIndex
:
31
,
foreground
:
6
}
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
6
,
18
,
0
),
[
{
endIndex
:
7
,
foreground
:
2
},
{
endIndex
:
12
,
foreground
:
3
}
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
7
,
18
,
0
),
[
{
endIndex
:
6
,
foreground
:
2
},
{
endIndex
:
11
,
foreground
:
3
}
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
6
,
17
,
0
),
[
{
endIndex
:
7
,
foreground
:
2
},
{
endIndex
:
11
,
foreground
:
3
}
]);
assertViewLineTokens
(
lineTokens
.
sliceAndInflate
(
6
,
19
,
0
),
[
{
endIndex
:
7
,
foreground
:
2
},
{
endIndex
:
12
,
foreground
:
3
},
{
endIndex
:
13
,
foreground
:
4
},
]);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录