Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
375ef990
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
375ef990
编写于
6月 03, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
https://github.com/microsoft/vscode/issues/99135
上级
64955f13
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
12 deletion
+43
-12
src/vs/workbench/contrib/markers/browser/markersModel.ts
src/vs/workbench/contrib/markers/browser/markersModel.ts
+20
-12
src/vs/workbench/contrib/markers/test/browser/markersModel.test.ts
...rkbench/contrib/markers/test/browser/markersModel.test.ts
+23
-0
未找到文件。
src/vs/workbench/contrib/markers/browser/markersModel.ts
浏览文件 @
375ef990
...
...
@@ -31,10 +31,6 @@ function compareResourceMarkers(a: ResourceMarkers, b: ResourceMarkers): number
return
res
;
}
function
compareMarkers
(
a
:
Marker
,
b
:
Marker
):
number
{
return
MarkerSeverity
.
compare
(
a
.
marker
.
severity
,
b
.
marker
.
severity
)
||
Range
.
compareRangesUsingStarts
(
a
.
marker
,
b
.
marker
);
}
export
class
ResourceMarkers
{
...
...
@@ -42,7 +38,8 @@ export class ResourceMarkers {
readonly
name
:
string
;
private
markersMap
=
new
ResourceMap
<
Marker
[]
>
();
private
_markersMap
=
new
ResourceMap
<
Marker
[]
>
();
private
_cachedMarkers
:
Marker
[]
|
undefined
;
private
_total
:
number
=
0
;
constructor
(
readonly
id
:
string
,
readonly
resource
:
URI
)
{
...
...
@@ -51,32 +48,43 @@ export class ResourceMarkers {
}
get
markers
():
readonly
Marker
[]
{
return
flatten
([...
this
.
markersMap
.
values
()]);
if
(
!
this
.
_cachedMarkers
)
{
this
.
_cachedMarkers
=
mergeSort
(
flatten
([...
this
.
_markersMap
.
values
()]),
ResourceMarkers
.
_compareMarkers
);
}
return
this
.
_cachedMarkers
;
}
has
(
uri
:
URI
)
{
return
this
.
markersMap
.
has
(
uri
);
return
this
.
_
markersMap
.
has
(
uri
);
}
set
(
uri
:
URI
,
marker
:
Marker
[])
{
this
.
delete
(
uri
);
if
(
isNonEmptyArray
(
marker
))
{
this
.
markersMap
.
set
(
uri
,
marker
);
this
.
_
markersMap
.
set
(
uri
,
marker
);
this
.
_total
+=
marker
.
length
;
this
.
_cachedMarkers
=
undefined
;
}
}
delete
(
uri
:
URI
)
{
let
array
=
this
.
markersMap
.
get
(
uri
);
let
array
=
this
.
_
markersMap
.
get
(
uri
);
if
(
array
)
{
this
.
_total
-=
array
.
length
;
this
.
markersMap
.
delete
(
uri
);
this
.
_cachedMarkers
=
undefined
;
this
.
_markersMap
.
delete
(
uri
);
}
}
get
total
()
{
return
this
.
_total
;
}
private
static
_compareMarkers
(
a
:
Marker
,
b
:
Marker
):
number
{
return
MarkerSeverity
.
compare
(
a
.
marker
.
severity
,
b
.
marker
.
severity
)
||
extUri
.
compare
(
a
.
resource
,
b
.
resource
)
||
Range
.
compareRangesUsingStarts
(
a
.
marker
,
b
.
marker
);
}
}
export
class
Marker
{
...
...
@@ -169,7 +177,7 @@ export class MarkersModel {
change
.
updated
.
add
(
resourceMarkers
);
}
const
markersCountByKey
=
new
Map
<
string
,
number
>
();
const
markers
=
mergeSort
(
rawMarkers
.
map
((
rawMarker
)
=>
{
const
markers
=
rawMarkers
.
map
((
rawMarker
)
=>
{
const
key
=
IMarkerData
.
makeKey
(
rawMarker
);
const
index
=
markersCountByKey
.
get
(
key
)
||
0
;
markersCountByKey
.
set
(
key
,
index
+
1
);
...
...
@@ -182,7 +190,7 @@ export class MarkersModel {
}
return
new
Marker
(
markerId
,
rawMarker
,
relatedInformation
);
})
,
compareMarkers
)
;
});
this
.
_total
-=
resourceMarkers
.
total
;
resourceMarkers
.
set
(
resource
,
markers
);
...
...
src/vs/workbench/contrib/markers/test/browser/markersModel.test.ts
浏览文件 @
375ef990
...
...
@@ -163,6 +163,29 @@ suite('MarkersModel Test', () => {
assert
.
equal
(
model
.
total
,
2
);
});
test
(
'
Problems are no sorted correctly #99135
'
,
function
()
{
const
model
=
new
TestMarkersModel
([]);
assert
.
equal
(
model
.
total
,
0
);
const
document
=
URI
.
parse
(
'
foo://test/path/file
'
);
const
frag1
=
URI
.
parse
(
'
foo://test/path/file#1
'
);
const
frag2
=
URI
.
parse
(
'
foo://test/path/file#2
'
);
model
.
setResourceMarkers
([[
frag1
,
[
{
...
aMarker
(),
resource
:
frag1
},
{
...
aMarker
(
undefined
,
MarkerSeverity
.
Warning
),
resource
:
frag1
},
]]]);
model
.
setResourceMarkers
([[
frag2
,
[
{
...
aMarker
(),
resource
:
frag2
}
]]]);
assert
.
equal
(
model
.
total
,
3
);
const
markers
=
model
.
getResourceMarkers
(
document
)?.
markers
;
assert
.
deepEqual
(
markers
?.
map
(
m
=>
m
.
marker
.
severity
),
[
MarkerSeverity
.
Error
,
MarkerSeverity
.
Error
,
MarkerSeverity
.
Warning
]);
assert
.
deepEqual
(
markers
?.
map
(
m
=>
m
.
marker
.
resource
.
toString
()),
[
frag1
.
toString
(),
frag2
.
toString
(),
frag1
.
toString
()]);
});
function
compareResource
(
a
:
ResourceMarkers
,
b
:
string
):
boolean
{
return
a
.
resource
.
toString
()
===
URI
.
file
(
b
).
toString
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录