Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a920f227
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,发现更多精彩内容 >>
提交
a920f227
编写于
1月 28, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #66685
上级
b257ca20
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
125 addition
and
66 deletion
+125
-66
src/vs/workbench/parts/markers/electron-browser/constants.ts
src/vs/workbench/parts/markers/electron-browser/constants.ts
+1
-0
src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts
...ch/parts/markers/electron-browser/markers.contribution.ts
+16
-2
src/vs/workbench/parts/markers/electron-browser/markersPanel.ts
.../workbench/parts/markers/electron-browser/markersPanel.ts
+18
-14
src/vs/workbench/parts/markers/electron-browser/markersPanelActions.ts
...nch/parts/markers/electron-browser/markersPanelActions.ts
+15
-2
src/vs/workbench/parts/markers/electron-browser/markersTreeViewer.ts
...bench/parts/markers/electron-browser/markersTreeViewer.ts
+75
-48
未找到文件。
src/vs/workbench/parts/markers/electron-browser/constants.ts
浏览文件 @
a920f227
...
...
@@ -16,6 +16,7 @@ export default {
MARKERS_PANEL_SHOW_SINGLELINE_MESSAGE
:
'
problems.action.showSinglelineMessage
'
,
MARKER_OPEN_SIDE_ACTION_ID
:
'
problems.action.openToSide
'
,
MARKER_SHOW_PANEL_ID
:
'
workbench.action.showErrorsWarnings
'
,
MARKER_SHOW_QUICK_FIX
:
'
problems.action.showQuickFixes
'
,
MarkerPanelFocusContextKey
:
new
RawContextKey
<
boolean
>
(
'
problemsViewFocus
'
,
false
),
MarkerFocusContextKey
:
new
RawContextKey
<
boolean
>
(
'
problemFocus
'
,
false
),
...
...
src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts
浏览文件 @
a920f227
...
...
@@ -53,6 +53,20 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
Constants
.
MARKER_SHOW_QUICK_FIX
,
weight
:
KeybindingWeight
.
WorkbenchContrib
,
when
:
Constants
.
MarkerFocusContextKey
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
US_DOT
,
handler
:
(
accessor
,
args
:
any
)
=>
{
const
markersPanel
=
(
<
MarkersPanel
>
accessor
.
get
(
IPanelService
).
getActivePanel
());
const
focusedElement
=
markersPanel
.
getFocusElement
();
if
(
focusedElement
instanceof
Marker
)
{
markersPanel
.
showQuickFixes
(
focusedElement
);
}
}
});
// configuration
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
registerConfiguration
({
'
id
'
:
'
problems
'
,
...
...
@@ -161,7 +175,7 @@ registerAction({
const
panelService
=
accessor
.
get
(
IPanelService
);
const
panel
=
panelService
.
getActivePanel
();
if
(
panel
instanceof
MarkersPanel
)
{
panel
.
markersView
State
.
multiline
=
true
;
panel
.
markersView
Model
.
multiline
=
true
;
}
},
title
:
localize
(
'
show multiline
'
,
"
Show message in multiple lines
"
),
...
...
@@ -177,7 +191,7 @@ registerAction({
const
panelService
=
accessor
.
get
(
IPanelService
);
const
panel
=
panelService
.
getActivePanel
();
if
(
panel
instanceof
MarkersPanel
)
{
panel
.
markersView
State
.
multiline
=
false
;
panel
.
markersView
Model
.
multiline
=
false
;
}
},
title
:
localize
(
'
show singleline
'
,
"
Show message in single line
"
),
...
...
src/vs/workbench/parts/markers/electron-browser/markersPanel.ts
浏览文件 @
a920f227
...
...
@@ -14,7 +14,7 @@ import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/
import
Constants
from
'
vs/workbench/parts/markers/electron-browser/constants
'
;
import
{
Marker
,
ResourceMarkers
,
RelatedInformation
,
MarkersModel
}
from
'
vs/workbench/parts/markers/electron-browser/markersModel
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
MarkersFilterActionItem
,
MarkersFilterAction
,
QuickFixAction
,
QuickFixActionItem
,
IMarkersFilterActionChangeEvent
,
IMarkerFilterController
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
MarkersFilterActionItem
,
MarkersFilterAction
,
IMarkersFilterActionChangeEvent
,
IMarkerFilterController
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
Messages
from
'
vs/workbench/parts/markers/electron-browser/messages
'
;
import
{
RangeHighlightDecorations
}
from
'
vs/workbench/browser/parts/editor/rangeDecorations
'
;
...
...
@@ -33,7 +33,7 @@ import { IExpression, getEmptyExpression } from 'vs/base/common/glob';
import
{
mixin
,
deepClone
}
from
'
vs/base/common/objects
'
;
import
{
IWorkspaceFolder
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
isAbsolute
,
join
}
from
'
vs/base/common/paths
'
;
import
{
FilterData
,
Filter
,
VirtualDelegate
,
ResourceMarkersRenderer
,
MarkerRenderer
,
RelatedInformationRenderer
,
TreeElement
,
MarkersTreeAccessibilityProvider
,
MarkersView
State
}
from
'
vs/workbench/parts/markers/electron-browser/markersTreeViewer
'
;
import
{
FilterData
,
Filter
,
VirtualDelegate
,
ResourceMarkersRenderer
,
MarkerRenderer
,
RelatedInformationRenderer
,
TreeElement
,
MarkersTreeAccessibilityProvider
,
MarkersView
Model
}
from
'
vs/workbench/parts/markers/electron-browser/markersTreeViewer
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
Separator
,
ActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -89,7 +89,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
private
cachedFilterStats
:
{
total
:
number
;
filtered
:
number
;
}
|
undefined
=
undefined
;
private
currentResourceGotAddedToMarkersData
:
boolean
=
false
;
readonly
markersView
State
:
MarkersViewState
;
readonly
markersView
Model
:
MarkersViewModel
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
...
...
@@ -109,8 +109,8 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
super
(
Constants
.
MARKERS_PANEL_ID
,
telemetryService
,
themeService
,
storageService
);
this
.
panelFoucusContextKey
=
Constants
.
MarkerPanelFocusContextKey
.
bindTo
(
contextKeyService
);
this
.
panelState
=
this
.
getMemento
(
StorageScope
.
WORKSPACE
);
this
.
markersView
State
=
new
MarkersViewState
(
this
.
panelState
[
'
multiline
'
]);
this
.
markersView
State
.
onDidChangeViewStat
e
(
this
.
onDidChangeViewState
,
this
,
this
.
disposables
);
this
.
markersView
Model
=
instantiationService
.
createInstance
(
MarkersViewModel
,
this
.
panelState
[
'
multiline
'
]);
this
.
markersView
Model
.
onDidChang
e
(
this
.
onDidChangeViewState
,
this
,
this
.
disposables
);
this
.
setCurrentActiveEditor
();
}
...
...
@@ -178,6 +178,13 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
return
this
.
actions
;
}
public
showQuickFixes
(
marker
:
Marker
):
void
{
const
viewModel
=
this
.
markersViewModel
.
getViewModel
(
marker
);
if
(
viewModel
)
{
viewModel
.
quickFixAction
.
run
();
}
}
public
openFileAtElement
(
element
:
any
,
preserveFocus
:
boolean
,
sideByside
:
boolean
,
pinned
:
boolean
):
boolean
{
const
{
resource
,
selection
,
event
,
data
}
=
element
instanceof
Marker
?
{
resource
:
element
.
resource
,
selection
:
element
.
range
,
event
:
'
problems.selectDiagnostic
'
,
data
:
this
.
getTelemetryData
(
element
.
marker
)
}
:
element
instanceof
RelatedInformation
?
{
resource
:
element
.
raw
.
resource
,
selection
:
element
.
raw
,
event
:
'
problems.selectRelatedInformation
'
,
data
:
this
.
getTelemetryData
(
element
.
marker
)
}
:
{
resource
:
null
,
selection
:
null
,
event
:
null
,
data
:
null
};
...
...
@@ -306,10 +313,10 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
treeLabels
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
ResourceLabels
,
this
));
const
virtualDelegate
=
new
VirtualDelegate
(
this
.
markersView
State
);
const
virtualDelegate
=
new
VirtualDelegate
(
this
.
markersView
Model
);
const
renderers
=
[
this
.
instantiationService
.
createInstance
(
ResourceMarkersRenderer
,
this
.
treeLabels
,
onDidChangeRenderNodeCount
.
event
),
this
.
instantiationService
.
createInstance
(
MarkerRenderer
,
this
.
markersView
State
,
a
=>
this
.
getActionItem
(
a
)
),
this
.
instantiationService
.
createInstance
(
MarkerRenderer
,
this
.
markersView
Model
),
this
.
instantiationService
.
createInstance
(
RelatedInformationRenderer
)
];
this
.
filter
=
new
Filter
();
...
...
@@ -408,11 +415,11 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
private
onDidChangeModel
(
resources
:
URI
[])
{
for
(
const
resource
of
resources
)
{
this
.
markersView
State
.
remove
(
resource
);
this
.
markersView
Model
.
remove
(
resource
);
const
resourceMarkers
=
this
.
markersWorkbenchService
.
markersModel
.
getResourceMarkers
(
resource
);
if
(
resourceMarkers
)
{
for
(
const
marker
of
resourceMarkers
.
markers
)
{
this
.
markersView
State
.
add
(
marker
);
this
.
markersView
Model
.
add
(
marker
);
}
}
}
...
...
@@ -657,9 +664,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
filterInputActionItem
=
this
.
instantiationService
.
createInstance
(
MarkersFilterActionItem
,
this
.
filterAction
,
this
);
return
this
.
filterInputActionItem
;
}
if
(
action
.
id
===
QuickFixAction
.
ID
)
{
return
this
.
instantiationService
.
createInstance
(
QuickFixActionItem
,
action
);
}
return
super
.
getActionItem
(
action
);
}
...
...
@@ -701,7 +705,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
panelState
[
'
filter
'
]
=
this
.
filterAction
.
filterText
;
this
.
panelState
[
'
filterHistory
'
]
=
this
.
filterAction
.
filterHistory
;
this
.
panelState
[
'
useFilesExclude
'
]
=
this
.
filterAction
.
useFilesExclude
;
this
.
panelState
[
'
multiline
'
]
=
this
.
markersView
State
.
multiline
;
this
.
panelState
[
'
multiline
'
]
=
this
.
markersView
Model
.
multiline
;
super
.
saveState
();
}
...
...
@@ -709,7 +713,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
public
dispose
():
void
{
super
.
dispose
();
this
.
tree
.
dispose
();
this
.
markersView
State
.
dispose
();
this
.
markersView
Model
.
dispose
();
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
\ No newline at end of file
src/vs/workbench/parts/markers/electron-browser/markersPanelActions.ts
浏览文件 @
a920f227
...
...
@@ -29,7 +29,7 @@ import { Marker } from 'vs/workbench/parts/markers/electron-browser/markersModel
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
FilterOptions
}
from
'
vs/workbench/parts/markers/electron-browser/markersFilterOptions
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -297,12 +297,16 @@ export class QuickFixAction extends Action {
private
updated
:
boolean
=
false
;
private
disposables
:
IDisposable
[]
=
[];
private
_onShowQuickFixes
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onShowQuickFixes
:
Event
<
void
>
=
this
.
_onShowQuickFixes
.
event
;
constructor
(
readonly
marker
:
Marker
,
@
IModelService
modelService
:
IModelService
,
@
IMarkersWorkbenchService
private
readonly
markerWorkbenchService
:
IMarkersWorkbenchService
,
)
{
super
(
QuickFixAction
.
ID
,
Messages
.
MARKERS_PANEL_ACTION_TOOLTIP_QUICKFIX
,
'
markers-panel-action-quickfix
'
,
false
);
this
.
disposables
.
push
(
this
.
_onShowQuickFixes
);
if
(
modelService
.
getModel
(
this
.
marker
.
resource
))
{
this
.
update
();
}
else
{
...
...
@@ -314,6 +318,11 @@ export class QuickFixAction extends Action {
}
}
run
():
Promise
<
void
>
{
this
.
_onShowQuickFixes
.
fire
();
return
Promise
.
resolve
();
}
private
update
():
void
{
if
(
!
this
.
updated
)
{
this
.
markerWorkbenchService
.
hasQuickFixes
(
this
.
marker
).
then
(
hasFixes
=>
this
.
enabled
=
hasFixes
);
...
...
@@ -338,13 +347,17 @@ export class QuickFixActionItem extends ActionItem {
public
onClick
(
event
:
DOM
.
EventLike
):
void
{
DOM
.
EventHelper
.
stop
(
event
,
true
);
this
.
showQuickFixes
();
}
public
showQuickFixes
():
void
{
if
(
!
this
.
element
)
{
return
;
}
const
elementPosition
=
DOM
.
getDomNodePagePosition
(
this
.
element
);
this
.
markerWorkbenchService
.
getQuickFixActions
((
<
QuickFixAction
>
this
.
getAction
()).
marker
).
then
(
actions
=>
{
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
({
x
:
elementPosition
.
left
+
10
,
y
:
elementPosition
.
top
+
elementPosition
.
height
}),
getAnchor
:
()
=>
({
x
:
elementPosition
.
left
+
10
,
y
:
elementPosition
.
top
+
elementPosition
.
height
+
4
}),
getActions
:
()
=>
actions
});
});
...
...
src/vs/workbench/parts/markers/electron-browser/markersTreeViewer.ts
浏览文件 @
a920f227
...
...
@@ -16,8 +16,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
attachBadgeStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IDisposable
,
dispose
,
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ActionBar
,
IActionItemProvider
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
QuickFixAction
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
QuickFixAction
,
QuickFixActionItem
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
...
...
@@ -76,12 +76,12 @@ const enum TemplateId {
export
class
VirtualDelegate
implements
IListVirtualDelegate
<
TreeElement
>
{
constructor
(
private
readonly
markersViewState
:
MarkersView
State
)
{
}
constructor
(
private
readonly
markersViewState
:
MarkersView
Model
)
{
}
getHeight
(
element
:
TreeElement
):
number
{
if
(
element
instanceof
Marker
)
{
const
view
State
=
this
.
markersViewState
.
getViewState
(
element
);
const
noOfLines
=
!
view
State
||
viewState
.
multiline
?
element
.
lines
.
length
:
1
;
const
view
Model
=
this
.
markersViewState
.
getViewModel
(
element
);
const
noOfLines
=
!
view
Model
||
viewModel
.
multiline
?
element
.
lines
.
length
:
1
;
return
noOfLines
*
22
;
}
return
22
;
...
...
@@ -201,8 +201,7 @@ export class FileResourceMarkersRenderer extends ResourceMarkersRenderer {
export
class
MarkerRenderer
implements
ITreeRenderer
<
Marker
,
MarkerFilterData
,
IMarkerTemplateData
>
{
constructor
(
private
readonly
markersViewState
:
MarkersViewState
,
private
actionItemProvider
:
IActionItemProvider
,
private
readonly
markersViewState
:
MarkersViewModel
,
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
)
{
}
...
...
@@ -210,7 +209,7 @@ export class MarkerRenderer implements ITreeRenderer<Marker, MarkerFilterData, I
renderTemplate
(
container
:
HTMLElement
):
IMarkerTemplateData
{
const
data
:
IMarkerTemplateData
=
Object
.
create
(
null
);
data
.
markerWidget
=
new
MarkerWidget
(
container
,
this
.
markersViewState
,
this
.
actionItemProvider
,
this
.
instantiationService
);
data
.
markerWidget
=
new
MarkerWidget
(
container
,
this
.
markersViewState
,
this
.
instantiationService
);
return
data
;
}
...
...
@@ -234,14 +233,15 @@ class MarkerWidget extends Disposable {
constructor
(
parent
:
HTMLElement
,
private
readonly
markersViewState
:
MarkersViewState
,
actionItemProvider
:
IActionItemProvider
,
private
instantiationService
:
IInstantiationService
private
readonly
markersViewModel
:
MarkersViewModel
,
instantiationService
:
IInstantiationService
)
{
super
();
this
.
actionBar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.actions
'
)),
{
actionItemProvider
}));
this
.
actionBar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.actions
'
)),
{
actionItemProvider
:
(
action
)
=>
action
.
id
===
QuickFixAction
.
ID
?
instantiationService
.
createInstance
(
QuickFixActionItem
,
action
)
:
null
}));
this
.
icon
=
dom
.
append
(
parent
,
dom
.
$
(
'
.icon
'
));
this
.
multilineActionbar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.multiline-actions
'
))
,
{
actionItemProvider
}
));
this
.
multilineActionbar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.multiline-actions
'
))));
this
.
messageAndDetailsContainer
=
dom
.
append
(
parent
,
dom
.
$
(
'
.marker-message-details
'
));
this
.
_register
(
toDisposable
(()
=>
this
.
disposables
=
dispose
(
this
.
disposables
)));
}
...
...
@@ -254,15 +254,17 @@ class MarkerWidget extends Disposable {
}
dom
.
clearNode
(
this
.
messageAndDetailsContainer
);
this
.
renderQuickfixActionbar
(
element
);
this
.
icon
.
className
=
'
marker-icon
'
+
MarkerWidget
.
iconClassNameFor
(
element
.
marker
);
this
.
renderQuickfixActionbar
(
element
);
this
.
renderMultilineActionbar
(
element
);
this
.
renderMessageAndDetails
(
element
,
filterData
);
}
private
renderQuickfixActionbar
(
marker
:
Marker
):
void
{
const
quickFixAction
=
this
.
instantiationService
.
createInstance
(
QuickFixAction
,
marker
);
const
viewModel
=
this
.
markersViewModel
.
getViewModel
(
marker
);
if
(
viewModel
)
{
const
quickFixAction
=
viewModel
.
quickFixAction
;
this
.
actionBar
.
push
([
quickFixAction
],
{
icon
:
true
,
label
:
false
});
dom
.
toggleClass
(
this
.
icon
,
'
quickFix
'
,
quickFixAction
.
enabled
);
quickFixAction
.
onDidChange
(({
enabled
})
=>
{
...
...
@@ -270,22 +272,29 @@ class MarkerWidget extends Disposable {
dom
.
toggleClass
(
this
.
icon
,
'
quickFix
'
,
enabled
);
}
},
this
,
this
.
disposables
);
quickFixAction
.
onShowQuickFixes
(()
=>
{
const
quickFixActionItem
=
<
QuickFixActionItem
>
this
.
actionBar
.
items
[
0
];
if
(
quickFixActionItem
)
{
quickFixActionItem
.
showQuickFixes
();
}
},
this
,
this
.
disposables
);
}
}
private
renderMultilineActionbar
(
marker
:
Marker
):
void
{
const
view
State
=
this
.
markersViewState
.
getViewState
(
marker
);
const
multiline
=
view
State
&&
viewState
.
multiline
;
const
view
Model
=
this
.
markersViewModel
.
getViewModel
(
marker
);
const
multiline
=
view
Model
&&
viewModel
.
multiline
;
const
action
=
new
Action
(
'
problems.action.toggleMultiline
'
);
action
.
enabled
=
view
State
&&
marker
.
lines
.
length
>
1
;
action
.
enabled
=
view
Model
&&
marker
.
lines
.
length
>
1
;
action
.
tooltip
=
multiline
?
localize
(
'
single line
'
,
"
Show message in single line
"
)
:
localize
(
'
multi line
'
,
"
Show message in multiple lines
"
);
action
.
class
=
multiline
?
'
octicon octicon-chevron-up
'
:
'
octicon octicon-chevron-down
'
;
action
.
run
=
()
=>
{
if
(
view
State
)
{
viewState
.
multiline
=
!
viewState
.
multiline
;
}
return
Promise
.
resolve
();
};
action
.
run
=
()
=>
{
if
(
view
Model
)
{
viewModel
.
multiline
=
!
viewModel
.
multiline
;
}
return
Promise
.
resolve
();
};
this
.
multilineActionbar
.
push
([
action
],
{
icon
:
true
,
label
:
false
});
}
private
renderMessageAndDetails
(
element
:
Marker
,
filterData
:
MarkerFilterData
)
{
const
{
marker
,
lines
}
=
element
;
const
viewState
=
this
.
markersView
State
.
getViewState
(
element
);
const
viewState
=
this
.
markersView
Model
.
getViewModel
(
element
);
const
multiline
=
!
viewState
||
viewState
.
multiline
;
const
lineMatches
=
filterData
&&
filterData
.
lineMatches
||
[];
const
messageContainer
=
dom
.
append
(
this
.
messageAndDetailsContainer
,
dom
.
$
(
'
.marker-message
'
));
...
...
@@ -461,10 +470,17 @@ export class Filter implements ITreeFilter<TreeElement, FilterData> {
}
}
export
class
MarkerView
State
extends
Disposable
{
export
class
MarkerView
Model
extends
Disposable
{
private
readonly
_onDidChangeViewState
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeViewState
:
Event
<
void
>
=
this
.
_onDidChangeViewState
.
event
;
private
readonly
_onDidChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
constructor
(
private
readonly
marker
:
Marker
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
();
}
private
_multiline
:
boolean
=
true
;
get
multiline
():
boolean
{
...
...
@@ -474,37 +490,48 @@ export class MarkerViewState extends Disposable {
set
multiline
(
value
:
boolean
)
{
if
(
this
.
_multiline
!==
value
)
{
this
.
_multiline
=
value
;
this
.
_onDidChange
ViewState
.
fire
();
this
.
_onDidChange
.
fire
();
}
}
private
_quickFixAction
:
QuickFixAction
;
get
quickFixAction
():
QuickFixAction
{
if
(
!
this
.
_quickFixAction
)
{
this
.
_quickFixAction
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
QuickFixAction
,
this
.
marker
));
}
return
this
.
_quickFixAction
;
}
}
export
class
MarkersView
State
extends
Disposable
{
export
class
MarkersView
Model
extends
Disposable
{
private
readonly
_onDidChange
ViewState
:
Emitter
<
Marker
|
undefined
>
=
this
.
_register
(
new
Emitter
<
Marker
|
undefined
>
());
readonly
onDidChange
ViewState
:
Event
<
Marker
|
undefined
>
=
this
.
_onDidChangeViewStat
e
.
event
;
private
readonly
_onDidChange
:
Emitter
<
Marker
|
undefined
>
=
this
.
_register
(
new
Emitter
<
Marker
|
undefined
>
());
readonly
onDidChange
:
Event
<
Marker
|
undefined
>
=
this
.
_onDidChang
e
.
event
;
private
readonly
markersViewStates
:
Map
<
string
,
{
view
State
:
MarkerViewState
,
disposables
:
IDisposable
[]
}
>
=
new
Map
<
string
,
{
viewState
:
MarkerViewState
,
disposables
:
IDisposable
[]
}
>
();
private
readonly
markersViewStates
:
Map
<
string
,
{
view
Model
:
MarkerViewModel
,
disposables
:
IDisposable
[]
}
>
=
new
Map
<
string
,
{
viewModel
:
MarkerViewModel
,
disposables
:
IDisposable
[]
}
>
();
private
readonly
markersPerResource
:
Map
<
string
,
Marker
[]
>
=
new
Map
<
string
,
Marker
[]
>
();
private
bulkUpdate
:
boolean
=
false
;
constructor
(
multiline
:
boolean
=
true
)
{
constructor
(
multiline
:
boolean
=
true
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
();
this
.
_multiline
=
multiline
;
}
add
(
marker
:
Marker
):
void
{
if
(
!
this
.
markersViewStates
.
has
(
marker
.
hash
))
{
const
disposables
:
IDisposable
[]
=
[]
;
const
viewState
=
new
MarkerViewState
()
;
view
State
.
multiline
=
this
.
multiline
;
view
State
.
onDidChangeViewStat
e
(()
=>
{
const
viewModel
=
this
.
instantiationService
.
createInstance
(
MarkerViewModel
,
marker
)
;
const
disposables
:
IDisposable
[]
=
[
viewModel
]
;
view
Model
.
multiline
=
this
.
multiline
;
view
Model
.
onDidChang
e
(()
=>
{
if
(
!
this
.
bulkUpdate
)
{
this
.
_onDidChange
ViewState
.
fire
(
marker
);
this
.
_onDidChange
.
fire
(
marker
);
}
},
this
,
disposables
);
this
.
markersViewStates
.
set
(
marker
.
hash
,
{
view
State
,
disposables
});
this
.
markersViewStates
.
set
(
marker
.
hash
,
{
view
Model
,
disposables
});
const
markers
=
this
.
markersPerResource
.
get
(
marker
.
resource
.
toString
())
||
[];
markers
.
push
(
marker
);
...
...
@@ -524,9 +551,9 @@ export class MarkersViewState extends Disposable {
this
.
markersPerResource
.
delete
(
resource
.
toString
());
}
getView
State
(
marker
:
Marker
):
MarkerViewState
|
null
{
getView
Model
(
marker
:
Marker
):
MarkerViewModel
|
null
{
const
value
=
this
.
markersViewStates
.
get
(
marker
.
hash
);
return
value
?
value
.
view
State
:
null
;
return
value
?
value
.
view
Model
:
null
;
}
private
_multiline
:
boolean
=
true
;
...
...
@@ -541,15 +568,15 @@ export class MarkersViewState extends Disposable {
changed
=
true
;
}
this
.
bulkUpdate
=
true
;
this
.
markersViewStates
.
forEach
(({
view
State
})
=>
{
if
(
view
State
.
multiline
!==
value
)
{
view
State
.
multiline
=
value
;
this
.
markersViewStates
.
forEach
(({
view
Model
})
=>
{
if
(
view
Model
.
multiline
!==
value
)
{
view
Model
.
multiline
=
value
;
changed
=
true
;
}
});
this
.
bulkUpdate
=
false
;
if
(
changed
)
{
this
.
_onDidChange
ViewState
.
fire
(
undefined
);
this
.
_onDidChange
.
fire
(
undefined
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录