Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9e4d7063
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,发现更多精彩内容 >>
提交
9e4d7063
编写于
4月 25, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add MessageItem#isCloseAffordance, fixes #5448
上级
ab509eeb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
9 deletion
+94
-9
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+6
-0
src/vs/workbench/api/node/extHostMessageService.ts
src/vs/workbench/api/node/extHostMessageService.ts
+16
-9
src/vs/workbench/test/node/api/extHostMessagerService.test.ts
...vs/workbench/test/node/api/extHostMessagerService.test.ts
+72
-0
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
9e4d7063
...
...
@@ -1212,6 +1212,12 @@ declare namespace vscode {
* A short title like 'Retry', 'Open Log' etc.
*/
title
:
string
;
/**
* Indicates that this item replaces the default
* 'Close' action.
*/
isCloseAffordance
?:
boolean
;
}
/**
...
...
src/vs/workbench/api/node/extHostMessageService.ts
浏览文件 @
9e4d7063
...
...
@@ -22,14 +22,15 @@ export class ExtHostMessageService {
showMessage
(
severity
:
Severity
,
message
:
string
,
commands
:
(
string
|
vscode
.
MessageItem
)[]):
Thenable
<
string
|
vscode
.
MessageItem
>
{
const
items
:
{
title
:
string
;
handle
:
number
;
}[]
=
[];
const
items
:
{
title
:
string
;
isCloseAffordance
:
boolean
;
handle
:
number
;
}[]
=
[];
for
(
let
handle
=
0
;
handle
<
commands
.
length
;
handle
++
)
{
let
command
=
commands
[
handle
];
if
(
typeof
command
===
'
string
'
)
{
items
.
push
({
title
:
command
,
handle
});
items
.
push
({
title
:
command
,
handle
,
isCloseAffordance
:
false
});
}
else
{
items
.
push
({
title
:
command
.
title
,
handle
});
let
{
title
,
isCloseAffordance
}
=
command
;
items
.
push
({
title
,
isCloseAffordance
,
handle
});
}
}
...
...
@@ -50,23 +51,29 @@ export class MainThreadMessageService {
this
.
_messageService
=
messageService
;
}
$showMessage
(
severity
:
Severity
,
message
:
string
,
commands
:
{
title
:
string
;
handle
:
number
;}[]):
Thenable
<
number
>
{
$showMessage
(
severity
:
Severity
,
message
:
string
,
commands
:
{
title
:
string
;
isCloseAffordance
:
boolean
;
handle
:
number
;}[]):
Thenable
<
number
>
{
let
hide
:
(
handle
?:
number
)
=>
void
;
let
actions
:
Action
[]
=
[];
actions
.
push
(
new
Action
(
'
__close
'
,
nls
.
localize
(
'
close
'
,
"
Close
"
),
undefined
,
true
,
()
=>
{
hide
();
return
Promise
.
as
(
undefined
);
}));
let
hasCloseAffordance
=
false
;
commands
.
forEach
(
command
=>
{
if
(
command
.
isCloseAffordance
===
true
)
{
hasCloseAffordance
=
true
;
}
actions
.
push
(
new
Action
(
'
_extension_message_handle_
'
+
command
.
handle
,
command
.
title
,
undefined
,
true
,
()
=>
{
hide
(
command
.
handle
);
return
Promise
.
as
(
undefined
);
}));
});
if
(
!
hasCloseAffordance
)
{
actions
.
unshift
(
new
Action
(
'
__close
'
,
nls
.
localize
(
'
close
'
,
"
Close
"
),
undefined
,
true
,
()
=>
{
hide
();
return
Promise
.
as
(
undefined
);
}));
}
return
new
Promise
<
number
>
((
c
)
=>
{
let
messageHide
:
Function
;
...
...
src/vs/workbench/test/node/api/extHostMessagerService.test.ts
0 → 100644
浏览文件 @
9e4d7063
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
MainThreadMessageService
}
from
'
vs/workbench/api/node/extHostMessageService
'
;
suite
(
'
ExtHostMessageService
'
,
function
()
{
test
(
'
propagte handle on select
'
,
function
()
{
let
service
=
new
MainThreadMessageService
(
<
any
>
{
show
(
sev
:
number
,
m
:
{
message
;
actions
:
Action
[]
})
{
assert
.
equal
(
m
.
actions
.
length
,
1
);
setImmediate
(()
=>
m
.
actions
[
0
].
run
());
return
()
=>
{
};
}
});
return
service
.
$showMessage
(
1
,
'
h
'
,
[{
handle
:
42
,
title
:
'
a thing
'
,
isCloseAffordance
:
true
}]).
then
(
handle
=>
{
assert
.
equal
(
handle
,
42
);
});
});
test
(
'
isCloseAffordance
'
,
function
()
{
let
actions
:
Action
[];
let
service
=
new
MainThreadMessageService
(
<
any
>
{
show
(
sev
:
number
,
m
:
{
message
;
actions
:
Action
[]
})
{
actions
=
m
.
actions
;
}
});
// default close action
service
.
$showMessage
(
1
,
''
,
[{
title
:
'
a thing
'
,
isCloseAffordance
:
false
,
handle
:
0
}]);
assert
.
equal
(
actions
.
length
,
2
);
let
[
first
,
second
]
=
actions
;
assert
.
equal
(
first
.
label
,
'
Close
'
);
assert
.
equal
(
second
.
label
,
'
a thing
'
);
// override close action
service
.
$showMessage
(
1
,
''
,
[{
title
:
'
a thing
'
,
isCloseAffordance
:
true
,
handle
:
0
}]);
assert
.
equal
(
actions
.
length
,
1
);
first
=
actions
[
0
];
assert
.
equal
(
first
.
label
,
'
a thing
'
);
});
test
(
'
hide on select
'
,
function
()
{
let
actions
:
Action
[];
let
c
:
number
;
let
service
=
new
MainThreadMessageService
(
<
any
>
{
show
(
sev
:
number
,
m
:
{
message
;
actions
:
Action
[]
})
{
c
=
0
;
actions
=
m
.
actions
;
return
()
=>
{
c
+=
1
;
};
}
});
service
.
$showMessage
(
1
,
''
,
[{
title
:
'
a thing
'
,
isCloseAffordance
:
true
,
handle
:
0
}]);
assert
.
equal
(
actions
.
length
,
1
);
actions
[
0
].
run
();
assert
.
equal
(
c
,
1
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录