Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a396179e
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,发现更多精彩内容 >>
提交
a396179e
编写于
4月 04, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - notifications should talk about closing not disposal
上级
99b6b5d6
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
59 addition
and
55 deletion
+59
-55
src/vs/platform/notification/common/notification.ts
src/vs/platform/notification/common/notification.ts
+13
-9
src/vs/workbench/api/electron-browser/mainThreadMessageService.ts
...orkbench/api/electron-browser/mainThreadMessageService.ts
+1
-1
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+1
-1
src/vs/workbench/browser/parts/notifications/notificationsCenter.ts
...kbench/browser/parts/notifications/notificationsCenter.ts
+2
-2
src/vs/workbench/browser/parts/notifications/notificationsCommands.ts
...ench/browser/parts/notifications/notificationsCommands.ts
+1
-1
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts
...kbench/browser/parts/notifications/notificationsToasts.ts
+2
-2
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts
...kbench/browser/parts/notifications/notificationsViewer.ts
+1
-1
src/vs/workbench/common/notifications.ts
src/vs/workbench/common/notifications.ts
+25
-25
src/vs/workbench/parts/files/electron-browser/saveErrorHandler.ts
...orkbench/parts/files/electron-browser/saveErrorHandler.ts
+4
-4
src/vs/workbench/services/notification/common/notificationService.ts
...bench/services/notification/common/notificationService.ts
+2
-2
src/vs/workbench/services/progress/browser/progressService2.ts
...s/workbench/services/progress/browser/progressService2.ts
+2
-2
src/vs/workbench/test/common/notifications.test.ts
src/vs/workbench/test/common/notifications.test.ts
+5
-5
未找到文件。
src/vs/platform/notification/common/notification.ts
浏览文件 @
a396179e
...
...
@@ -7,7 +7,6 @@
import
BaseSeverity
from
'
vs/base/common/severity
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -89,12 +88,12 @@ export interface INotificationProgress {
done
():
void
;
}
export
interface
INotificationHandle
extends
IDisposable
{
export
interface
INotificationHandle
{
/**
* Will be fired once the notification is
disp
osed.
* Will be fired once the notification is
cl
osed.
*/
readonly
onDid
Disp
ose
:
Event
<
void
>
;
readonly
onDid
Cl
ose
:
Event
<
void
>
;
/**
* Allows to indicate progress on the notification even after the
...
...
@@ -118,6 +117,11 @@ export interface INotificationHandle extends IDisposable {
* notification is already visible.
*/
updateActions
(
actions
?:
INotificationActions
):
void
;
/**
* Hide the notification and remove it from the notification center.
*/
close
():
void
;
}
export
interface
IPromptChoice
{
...
...
@@ -199,18 +203,18 @@ export interface INotificationService {
export
class
NoOpNotification
implements
INotificationHandle
{
readonly
progress
=
new
NoOpProgress
();
private
readonly
_onDid
Disp
ose
:
Emitter
<
void
>
=
new
Emitter
();
private
readonly
_onDid
Cl
ose
:
Emitter
<
void
>
=
new
Emitter
();
public
get
onDid
Disp
ose
():
Event
<
void
>
{
return
this
.
_onDid
Disp
ose
.
event
;
public
get
onDid
Cl
ose
():
Event
<
void
>
{
return
this
.
_onDid
Cl
ose
.
event
;
}
updateSeverity
(
severity
:
Severity
):
void
{
}
updateMessage
(
message
:
NotificationMessage
):
void
{
}
updateActions
(
actions
?:
INotificationActions
):
void
{
}
disp
ose
():
void
{
this
.
_onDid
Disp
ose
.
dispose
();
cl
ose
():
void
{
this
.
_onDid
Cl
ose
.
dispose
();
}
}
...
...
src/vs/workbench/api/electron-browser/mainThreadMessageService.ts
浏览文件 @
a396179e
...
...
@@ -92,7 +92,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
// if promise has not been resolved yet, now is the time to ensure a return value
// otherwise if already resolved it means the user clicked one of the buttons
once
(
messageHandle
.
onDid
Disp
ose
)(()
=>
{
once
(
messageHandle
.
onDid
Cl
ose
)(()
=>
{
dispose
(...
primaryActions
,
...
secondaryActions
);
resolve
(
undefined
);
});
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
a396179e
...
...
@@ -559,7 +559,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
actions
});
once
(
handle
.
onDid
Disp
ose
)(()
=>
dispose
(
actions
.
primary
));
once
(
handle
.
onDid
Cl
ose
)(()
=>
dispose
(
actions
.
primary
));
}
this
.
editorGroupsControl
.
updateProgress
(
position
,
ProgressState
.
DONE
);
...
...
src/vs/workbench/browser/parts/notifications/notificationsCenter.ts
浏览文件 @
a396179e
...
...
@@ -289,9 +289,9 @@ export class NotificationsCenter extends Themable {
// Hide notifications center first
this
.
hide
();
//
Disp
ose all
//
Cl
ose all
while
(
this
.
model
.
notifications
.
length
)
{
this
.
model
.
notifications
[
0
].
disp
ose
();
this
.
model
.
notifications
[
0
].
cl
ose
();
}
}
}
...
...
src/vs/workbench/browser/parts/notifications/notificationsCommands.ts
浏览文件 @
a396179e
...
...
@@ -115,7 +115,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl
handler
:
(
accessor
,
args
?:
any
)
=>
{
const
notification
=
getNotificationFromContext
(
accessor
.
get
(
IListService
),
args
);
if
(
notification
)
{
notification
.
disp
ose
();
notification
.
cl
ose
();
}
}
});
...
...
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts
浏览文件 @
a396179e
...
...
@@ -168,8 +168,8 @@ export class NotificationsToasts extends Themable {
}
}));
// Remove when item gets
disp
osed
once
(
item
.
onDid
Disp
ose
)(()
=>
{
// Remove when item gets
cl
osed
once
(
item
.
onDid
Cl
ose
)(()
=>
{
this
.
removeToast
(
item
);
});
...
...
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts
浏览文件 @
a396179e
...
...
@@ -442,7 +442,7 @@ export class NotificationTemplateRenderer {
this
.
actionRunner
.
run
(
action
,
notification
);
// Hide notification
notification
.
disp
ose
();
notification
.
cl
ose
();
}));
this
.
inputDisposeables
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
...
...
src/vs/workbench/common/notifications.ts
浏览文件 @
a396179e
...
...
@@ -44,21 +44,21 @@ export interface INotificationChangeEvent {
}
export
class
NotificationHandle
implements
INotificationHandle
{
private
readonly
_onDid
Disp
ose
:
Emitter
<
void
>
=
new
Emitter
();
private
readonly
_onDid
Cl
ose
:
Emitter
<
void
>
=
new
Emitter
();
constructor
(
private
item
:
INotificationViewItem
,
private
disp
oseItem
:
(
item
:
INotificationViewItem
)
=>
void
)
{
constructor
(
private
item
:
INotificationViewItem
,
private
cl
oseItem
:
(
item
:
INotificationViewItem
)
=>
void
)
{
this
.
registerListeners
();
}
private
registerListeners
():
void
{
once
(
this
.
item
.
onDid
Disp
ose
)(()
=>
{
this
.
_onDid
Disp
ose
.
fire
();
this
.
_onDid
Disp
ose
.
dispose
();
once
(
this
.
item
.
onDid
Cl
ose
)(()
=>
{
this
.
_onDid
Cl
ose
.
fire
();
this
.
_onDid
Cl
ose
.
dispose
();
});
}
public
get
onDid
Disp
ose
():
Event
<
void
>
{
return
this
.
_onDid
Disp
ose
.
event
;
public
get
onDid
Cl
ose
():
Event
<
void
>
{
return
this
.
_onDid
Cl
ose
.
event
;
}
public
get
progress
():
INotificationProgress
{
...
...
@@ -77,9 +77,9 @@ export class NotificationHandle implements INotificationHandle {
this
.
item
.
updateActions
(
actions
);
}
public
disp
ose
():
void
{
this
.
disp
oseItem
(
this
.
item
);
this
.
_onDid
Disp
ose
.
dispose
();
public
cl
ose
():
void
{
this
.
cl
oseItem
(
this
.
item
);
this
.
_onDid
Cl
ose
.
dispose
();
}
}
...
...
@@ -117,7 +117,7 @@ export class NotificationsModel implements INotificationsModel {
// Deduplicate
const
duplicate
=
this
.
findNotification
(
item
);
if
(
duplicate
)
{
duplicate
.
disp
ose
();
duplicate
.
cl
ose
();
}
// Add to list as first entry
...
...
@@ -127,15 +127,15 @@ export class NotificationsModel implements INotificationsModel {
this
.
_onDidNotificationChange
.
fire
({
item
,
index
:
0
,
kind
:
NotificationChangeType
.
ADD
});
// Wrap into handle
return
new
NotificationHandle
(
item
,
item
=>
this
.
disp
oseItem
(
item
));
return
new
NotificationHandle
(
item
,
item
=>
this
.
cl
oseItem
(
item
));
}
private
disp
oseItem
(
item
:
INotificationViewItem
):
void
{
private
cl
oseItem
(
item
:
INotificationViewItem
):
void
{
const
liveItem
=
this
.
findNotification
(
item
);
if
(
liveItem
&&
liveItem
!==
item
)
{
liveItem
.
dispose
();
// item could have been replaced with another one, make sure to disp
ose the live item
liveItem
.
close
();
// item could have been replaced with another one, make sure to cl
ose the live item
}
else
{
item
.
dispose
();
// otherwise just disp
ose the item that was passed in
item
.
close
();
// otherwise just cl
ose the item that was passed in
}
}
...
...
@@ -174,7 +174,7 @@ export class NotificationsModel implements INotificationsModel {
}
});
once
(
item
.
onDid
Disp
ose
)(()
=>
{
once
(
item
.
onDid
Cl
ose
)(()
=>
{
itemExpansionChangeListener
.
dispose
();
itemLabelChangeListener
.
dispose
();
...
...
@@ -204,7 +204,7 @@ export interface INotificationViewItem {
readonly
canCollapse
:
boolean
;
readonly
onDidExpansionChange
:
Event
<
void
>
;
readonly
onDid
Disp
ose
:
Event
<
void
>
;
readonly
onDid
Cl
ose
:
Event
<
void
>
;
readonly
onDidLabelChange
:
Event
<
INotificationViewItemLabelChangeEvent
>
;
expand
():
void
;
...
...
@@ -217,7 +217,7 @@ export interface INotificationViewItem {
updateMessage
(
message
:
NotificationMessage
):
void
;
updateActions
(
actions
?:
INotificationActions
):
void
;
disp
ose
():
void
;
cl
ose
():
void
;
equals
(
item
:
INotificationViewItem
);
}
...
...
@@ -359,7 +359,7 @@ export class NotificationViewItem implements INotificationViewItem {
private
_progress
:
NotificationViewItemProgress
;
private
readonly
_onDidExpansionChange
:
Emitter
<
void
>
;
private
readonly
_onDid
Disp
ose
:
Emitter
<
void
>
;
private
readonly
_onDid
Cl
ose
:
Emitter
<
void
>
;
private
readonly
_onDidLabelChange
:
Emitter
<
INotificationViewItemLabelChangeEvent
>
;
public
static
create
(
notification
:
INotification
):
INotificationViewItem
{
...
...
@@ -435,8 +435,8 @@ export class NotificationViewItem implements INotificationViewItem {
this
.
_onDidLabelChange
=
new
Emitter
<
INotificationViewItemLabelChangeEvent
>
();
this
.
toDispose
.
push
(
this
.
_onDidLabelChange
);
this
.
_onDid
Disp
ose
=
new
Emitter
<
void
>
();
this
.
toDispose
.
push
(
this
.
_onDid
Disp
ose
);
this
.
_onDid
Cl
ose
=
new
Emitter
<
void
>
();
this
.
toDispose
.
push
(
this
.
_onDid
Cl
ose
);
}
private
setActions
(
actions
:
INotificationActions
):
void
{
...
...
@@ -464,8 +464,8 @@ export class NotificationViewItem implements INotificationViewItem {
return
this
.
_onDidLabelChange
.
event
;
}
public
get
onDid
Disp
ose
():
Event
<
void
>
{
return
this
.
_onDid
Disp
ose
.
event
;
public
get
onDid
Cl
ose
():
Event
<
void
>
{
return
this
.
_onDid
Cl
ose
.
event
;
}
public
get
canCollapse
():
boolean
{
...
...
@@ -556,8 +556,8 @@ export class NotificationViewItem implements INotificationViewItem {
}
}
public
disp
ose
():
void
{
this
.
_onDid
Disp
ose
.
fire
();
public
cl
ose
():
void
{
this
.
_onDid
Cl
ose
.
fire
();
this
.
toDispose
=
dispose
(
this
.
toDispose
);
}
...
...
src/vs/workbench/parts/files/electron-browser/saveErrorHandler.ts
浏览文件 @
a396179e
...
...
@@ -102,7 +102,7 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
private
onFileSavedOrReverted
(
resource
:
URI
):
void
{
const
messageHandle
=
this
.
messages
.
get
(
resource
);
if
(
messageHandle
)
{
messageHandle
.
disp
ose
();
messageHandle
.
cl
ose
();
this
.
messages
.
delete
(
resource
);
}
}
...
...
@@ -179,7 +179,7 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
// Show message and keep function to hide in case the file gets saved/reverted
const
handle
=
this
.
notificationService
.
notify
({
severity
:
Severity
.
Error
,
message
,
actions
});
once
(
handle
.
onDid
Disp
ose
)(()
=>
dispose
(...
actions
.
primary
,
...
actions
.
secondary
));
once
(
handle
.
onDid
Cl
ose
)(()
=>
dispose
(...
actions
.
primary
,
...
actions
.
secondary
));
this
.
messages
.
set
(
model
.
getResource
(),
handle
);
}
...
...
@@ -193,7 +193,7 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
const
pendingResolveSaveConflictMessages
:
INotificationHandle
[]
=
[];
function
clearPendingResolveSaveConflictMessages
():
void
{
while
(
pendingResolveSaveConflictMessages
.
length
>
0
)
{
pendingResolveSaveConflictMessages
.
pop
().
disp
ose
();
pendingResolveSaveConflictMessages
.
pop
().
cl
ose
();
}
}
...
...
@@ -265,7 +265,7 @@ class ResolveSaveConflictAction extends Action {
actions
.
secondary
.
push
(
this
.
instantiationService
.
createInstance
(
DoNotShowResolveConflictLearnMoreAction
));
const
handle
=
this
.
notificationService
.
notify
({
severity
:
Severity
.
Info
,
message
:
conflictEditorHelp
,
actions
});
once
(
handle
.
onDid
Disp
ose
)(()
=>
dispose
(...
actions
.
primary
,
...
actions
.
secondary
));
once
(
handle
.
onDid
Cl
ose
)(()
=>
dispose
(...
actions
.
primary
,
...
actions
.
secondary
));
pendingResolveSaveConflictMessages
.
push
(
handle
);
});
}
...
...
src/vs/workbench/services/notification/common/notificationService.ts
浏览文件 @
a396179e
...
...
@@ -80,7 +80,7 @@ export class NotificationService implements INotificationService {
// Close notification unless we are told to keep open
if
(
!
choice
.
keepOpen
)
{
handle
.
disp
ose
();
handle
.
cl
ose
();
}
return
TPromise
.
as
(
void
0
);
...
...
@@ -96,7 +96,7 @@ export class NotificationService implements INotificationService {
// Show notification with actions
handle
=
this
.
notify
({
severity
,
message
,
actions
});
once
(
handle
.
onDid
Disp
ose
)(()
=>
{
once
(
handle
.
onDid
Cl
ose
)(()
=>
{
// Cleanup when notification gets disposed
dispose
(...
actions
.
primary
,
...
actions
.
secondary
);
...
...
src/vs/workbench/services/progress/browser/progressService2.ts
浏览文件 @
a396179e
...
...
@@ -203,7 +203,7 @@ export class ProgressService2 implements IProgressService2 {
updateProgress
(
handle
,
increment
);
once
(
handle
.
onDid
Disp
ose
)(()
=>
{
once
(
handle
.
onDid
Cl
ose
)(()
=>
{
dispose
(
toDispose
);
});
...
...
@@ -247,7 +247,7 @@ export class ProgressService2 implements IProgressService2 {
// Show progress for at least 800ms and then hide once done or canceled
always
(
TPromise
.
join
([
TPromise
.
timeout
(
800
),
p
]),
()
=>
{
if
(
handle
)
{
handle
.
disp
ose
();
handle
.
cl
ose
();
}
});
...
...
src/vs/workbench/test/common/notifications.test.ts
浏览文件 @
a396179e
...
...
@@ -96,11 +96,11 @@ suite('Notifications', () => {
assert
.
equal
(
called
,
1
);
called
=
0
;
item1
.
onDid
Disp
ose
(()
=>
{
item1
.
onDid
Cl
ose
(()
=>
{
called
++
;
});
item1
.
disp
ose
();
item1
.
cl
ose
();
assert
.
equal
(
called
,
1
);
// Error with Action
...
...
@@ -157,11 +157,11 @@ suite('Notifications', () => {
assert
.
equal
(
model
.
notifications
.
length
,
3
);
let
called
=
0
;
item1Handle
.
onDid
Disp
ose
(()
=>
{
item1Handle
.
onDid
Cl
ose
(()
=>
{
called
++
;
});
item1Handle
.
disp
ose
();
item1Handle
.
cl
ose
();
assert
.
equal
(
called
,
1
);
assert
.
equal
(
model
.
notifications
.
length
,
2
);
assert
.
equal
(
lastEvent
.
item
.
severity
,
item1
.
severity
);
...
...
@@ -176,7 +176,7 @@ suite('Notifications', () => {
assert
.
equal
(
lastEvent
.
index
,
0
);
assert
.
equal
(
lastEvent
.
kind
,
NotificationChangeType
.
ADD
);
item2Handle
.
disp
ose
();
item2Handle
.
cl
ose
();
assert
.
equal
(
model
.
notifications
.
length
,
1
);
assert
.
equal
(
lastEvent
.
item
.
severity
,
item2Duplicate
.
severity
);
assert
.
equal
(
lastEvent
.
item
.
message
.
value
,
item2Duplicate
.
message
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录