Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a158a8d4
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,发现更多精彩内容 >>
提交
a158a8d4
编写于
10月 16, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #60834
上级
299050a8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
24 deletion
+44
-24
src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts
...ch/parts/extensions/electron-browser/extensionsActions.ts
+12
-20
src/vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts
...xtensions/test/electron-browser/extensionsActions.test.ts
+32
-4
未找到文件。
src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts
浏览文件 @
a158a8d4
...
@@ -966,7 +966,6 @@ export class ReloadAction extends Action {
...
@@ -966,7 +966,6 @@ export class ReloadAction extends Action {
get
extension
():
IExtension
{
return
this
.
_extension
;
}
get
extension
():
IExtension
{
return
this
.
_extension
;
}
set
extension
(
extension
:
IExtension
)
{
this
.
_extension
=
extension
;
this
.
update
();
}
set
extension
(
extension
:
IExtension
)
{
this
.
_extension
=
extension
;
this
.
update
();
}
reloadMessage
:
string
=
''
;
private
throttler
:
Throttler
;
private
throttler
:
Throttler
;
constructor
(
constructor
(
...
@@ -991,7 +990,6 @@ export class ReloadAction extends Action {
...
@@ -991,7 +990,6 @@ export class ReloadAction extends Action {
this
.
throttler
.
queue
(()
=>
{
this
.
throttler
.
queue
(()
=>
{
this
.
enabled
=
false
;
this
.
enabled
=
false
;
this
.
tooltip
=
''
;
this
.
tooltip
=
''
;
this
.
reloadMessage
=
''
;
if
(
!
this
.
extension
)
{
if
(
!
this
.
extension
)
{
return
Promise
.
resolve
<
void
>
(
null
);
return
Promise
.
resolve
<
void
>
(
null
);
}
}
...
@@ -999,15 +997,20 @@ export class ReloadAction extends Action {
...
@@ -999,15 +997,20 @@ export class ReloadAction extends Action {
if
(
state
===
ExtensionState
.
Installing
||
state
===
ExtensionState
.
Uninstalling
)
{
if
(
state
===
ExtensionState
.
Installing
||
state
===
ExtensionState
.
Uninstalling
)
{
return
Promise
.
resolve
<
void
>
(
null
);
return
Promise
.
resolve
<
void
>
(
null
);
}
}
const
installed
=
this
.
extensionsWorkbenchService
.
local
.
filter
(
e
=>
e
.
id
===
this
.
extension
.
id
)[
0
];
const
local
=
this
.
extension
.
local
||
(
installed
&&
installed
.
local
);
if
(
local
&&
local
.
manifest
&&
local
.
manifest
.
contributes
&&
local
.
manifest
.
contributes
.
localizations
&&
local
.
manifest
.
contributes
.
localizations
.
length
>
0
)
{
return
Promise
.
resolve
<
void
>
(
null
);
}
return
this
.
extensionService
.
getExtensions
()
return
this
.
extensionService
.
getExtensions
()
.
then
(
runningExtensions
=>
this
.
computeReloadState
(
runningExtensions
));
.
then
(
runningExtensions
=>
this
.
computeReloadState
(
runningExtensions
,
installed
));
}).
then
(()
=>
{
}).
then
(()
=>
{
this
.
class
=
this
.
enabled
?
ReloadAction
.
EnabledClass
:
ReloadAction
.
DisabledClass
;
this
.
class
=
this
.
enabled
?
ReloadAction
.
EnabledClass
:
ReloadAction
.
DisabledClass
;
this
.
label
=
this
.
useLongLabel
?
this
.
tooltip
:
localize
(
'
reloadAction
'
,
"
Reload
"
);
});
});
}
}
private
computeReloadState
(
runningExtensions
:
IExtensionDescription
[]):
void
{
private
computeReloadState
(
runningExtensions
:
IExtensionDescription
[],
installed
:
IExtension
):
void
{
const
installed
=
this
.
extensionsWorkbenchService
.
local
.
filter
(
e
=>
e
.
id
===
this
.
extension
.
id
)[
0
];
const
isUninstalled
=
this
.
extension
.
state
===
ExtensionState
.
Uninstalled
;
const
isUninstalled
=
this
.
extension
.
state
===
ExtensionState
.
Uninstalled
;
const
isDisabled
=
this
.
extension
.
local
?
!
this
.
extensionEnablementService
.
isEnabled
(
this
.
extension
.
local
)
:
false
;
const
isDisabled
=
this
.
extension
.
local
?
!
this
.
extensionEnablementService
.
isEnabled
(
this
.
extension
.
local
)
:
false
;
const
runningExtension
=
runningExtensions
.
filter
(
e
=>
areSameExtensions
(
e
,
this
.
extension
))[
0
];
const
runningExtension
=
runningExtensions
.
filter
(
e
=>
areSameExtensions
(
e
,
this
.
extension
))[
0
];
...
@@ -1018,15 +1021,13 @@ export class ReloadAction extends Action {
...
@@ -1018,15 +1021,13 @@ export class ReloadAction extends Action {
if
(
isDifferentVersionRunning
&&
!
isDisabled
)
{
if
(
isDifferentVersionRunning
&&
!
isDisabled
)
{
// Requires reload to run the updated extension
// Requires reload to run the updated extension
this
.
enabled
=
true
;
this
.
enabled
=
true
;
this
.
setTooltip
(
localize
(
'
postUpdateTooltip
'
,
"
Reload to Update
"
));
this
.
tooltip
=
localize
(
'
postUpdateTooltip
'
,
"
Reload to Update
"
);
this
.
reloadMessage
=
localize
(
'
postUpdateMessage
'
,
"
Reload this window to activate the updated extension '{0}'?
"
,
this
.
extension
.
displayName
);
return
;
return
;
}
}
if
(
isDisabled
)
{
if
(
isDisabled
)
{
// Requires reload to disable the extension
// Requires reload to disable the extension
this
.
enabled
=
true
;
this
.
enabled
=
true
;
this
.
setTooltip
(
localize
(
'
postDisableTooltip
'
,
"
Reload to Deactivate
"
));
this
.
tooltip
=
localize
(
'
postDisableTooltip
'
,
"
Reload to Deactivate
"
);
this
.
reloadMessage
=
localize
(
'
postDisableMessage
'
,
"
Reload this window to deactivate the extension '{0}'?
"
,
this
.
extension
.
displayName
);
return
;
return
;
}
}
}
else
{
}
else
{
...
@@ -1036,8 +1037,7 @@ export class ReloadAction extends Action {
...
@@ -1036,8 +1037,7 @@ export class ReloadAction extends Action {
if
(
extensionServer
&&
extensionServer
.
authority
===
localServer
.
authority
&&
!
isDisabled
)
{
if
(
extensionServer
&&
extensionServer
.
authority
===
localServer
.
authority
&&
!
isDisabled
)
{
// Requires reload to enable the extension
// Requires reload to enable the extension
this
.
enabled
=
true
;
this
.
enabled
=
true
;
this
.
setTooltip
(
localize
(
'
postEnableTooltip
'
,
"
Reload to Activate
"
));
this
.
tooltip
=
localize
(
'
postEnableTooltip
'
,
"
Reload to Activate
"
);
this
.
reloadMessage
=
localize
(
'
postEnableMessage
'
,
"
Reload this window to activate the extension '{0}'?
"
,
this
.
extension
.
displayName
);
return
;
return
;
}
}
}
}
...
@@ -1047,19 +1047,11 @@ export class ReloadAction extends Action {
...
@@ -1047,19 +1047,11 @@ export class ReloadAction extends Action {
if
(
isUninstalled
&&
runningExtension
)
{
if
(
isUninstalled
&&
runningExtension
)
{
// Requires reload to deactivate the extension
// Requires reload to deactivate the extension
this
.
enabled
=
true
;
this
.
enabled
=
true
;
this
.
setTooltip
(
localize
(
'
postUninstallTooltip
'
,
"
Reload to Deactivate
"
));
this
.
tooltip
=
localize
(
'
postUninstallTooltip
'
,
"
Reload to Deactivate
"
);
this
.
reloadMessage
=
localize
(
'
postUninstallMessage
'
,
"
Reload this window to deactivate the uninstalled extension '{0}'?
"
,
this
.
extension
.
displayName
);
return
;
return
;
}
}
}
}
private
setTooltip
(
text
:
string
)
{
if
(
this
.
useLongLabel
)
{
this
.
label
=
text
;
}
else
{
this
.
tooltip
=
text
;
}
}
run
():
Promise
<
any
>
{
run
():
Promise
<
any
>
{
return
Promise
.
resolve
(
this
.
windowService
.
reloadWindow
());
return
Promise
.
resolve
(
this
.
windowService
.
reloadWindow
());
}
}
...
...
src/vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts
浏览文件 @
a158a8d4
...
@@ -11,7 +11,7 @@ import * as ExtensionsActions from 'vs/workbench/parts/extensions/electron-brows
...
@@ -11,7 +11,7 @@ import * as ExtensionsActions from 'vs/workbench/parts/extensions/electron-brows
import
{
ExtensionsWorkbenchService
}
from
'
vs/workbench/parts/extensions/node/extensionsWorkbenchService
'
;
import
{
ExtensionsWorkbenchService
}
from
'
vs/workbench/parts/extensions/node/extensionsWorkbenchService
'
;
import
{
import
{
IExtensionManagementService
,
IExtensionGalleryService
,
IExtensionEnablementService
,
IExtensionTipsService
,
ILocalExtension
,
LocalExtensionType
,
IGalleryExtension
,
IExtensionManagementService
,
IExtensionGalleryService
,
IExtensionEnablementService
,
IExtensionTipsService
,
ILocalExtension
,
LocalExtensionType
,
IGalleryExtension
,
DidInstallExtensionEvent
,
DidUninstallExtensionEvent
,
InstallExtensionEvent
,
IExtensionIdentifier
,
EnablementState
,
InstallOperation
,
IExtensionManagementServerService
,
IExtensionManagementServer
DidInstallExtensionEvent
,
DidUninstallExtensionEvent
,
InstallExtensionEvent
,
IExtensionIdentifier
,
EnablementState
,
InstallOperation
,
IExtensionManagementServerService
,
IExtensionManagementServer
,
IExtensionContributions
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
getGalleryExtensionId
,
getGalleryExtensionIdFromLocal
}
from
'
vs/platform/extensionManagement/common/extensionManagementUtil
'
;
import
{
getGalleryExtensionId
,
getGalleryExtensionIdFromLocal
}
from
'
vs/platform/extensionManagement/common/extensionManagementUtil
'
;
import
{
ExtensionManagementService
,
getLocalExtensionIdFromGallery
,
getLocalExtensionIdFromManifest
}
from
'
vs/platform/extensionManagement/node/extensionManagementService
'
;
import
{
ExtensionManagementService
,
getLocalExtensionIdFromGallery
,
getLocalExtensionIdFromManifest
}
from
'
vs/platform/extensionManagement/node/extensionManagementService
'
;
...
@@ -1166,7 +1166,6 @@ suite('ExtensionsActions Test', () => {
...
@@ -1166,7 +1166,6 @@ suite('ExtensionsActions Test', () => {
.
then
(()
=>
{
.
then
(()
=>
{
assert
.
ok
(
testObject
.
enabled
);
assert
.
ok
(
testObject
.
enabled
);
assert
.
equal
(
'
Reload to Deactivate
'
,
testObject
.
tooltip
);
assert
.
equal
(
'
Reload to Deactivate
'
,
testObject
.
tooltip
);
assert
.
equal
(
`Reload this window to deactivate the extension 'a'?`
,
testObject
.
reloadMessage
);
});
});
});
});
});
});
...
@@ -1201,7 +1200,6 @@ suite('ExtensionsActions Test', () => {
...
@@ -1201,7 +1200,6 @@ suite('ExtensionsActions Test', () => {
.
then
(()
=>
{
.
then
(()
=>
{
assert
.
ok
(
testObject
.
enabled
);
assert
.
ok
(
testObject
.
enabled
);
assert
.
equal
(
'
Reload to Activate
'
,
testObject
.
tooltip
);
assert
.
equal
(
'
Reload to Activate
'
,
testObject
.
tooltip
);
assert
.
equal
(
`Reload this window to activate the extension 'a'?`
,
testObject
.
reloadMessage
);
});
});
});
});
});
});
...
@@ -1244,13 +1242,43 @@ suite('ExtensionsActions Test', () => {
...
@@ -1244,13 +1242,43 @@ suite('ExtensionsActions Test', () => {
.
then
(()
=>
{
.
then
(()
=>
{
assert
.
ok
(
testObject
.
enabled
);
assert
.
ok
(
testObject
.
enabled
);
assert
.
equal
(
'
Reload to Activate
'
,
testObject
.
tooltip
);
assert
.
equal
(
'
Reload to Activate
'
,
testObject
.
tooltip
);
assert
.
equal
(
`Reload this window to activate the extension 'a'?`
,
testObject
.
reloadMessage
);
});
});
});
});
});
});
});
});
test
(
'
Test ReloadAction when a localization extension is newly installed
'
,
async
()
=>
{
instantiationService
.
stubPromise
(
IExtensionService
,
'
getExtensions
'
,
[{
id
:
'
pub.b
'
,
extensionLocation
:
URI
.
file
(
'
pub.b
'
)
}]);
const
testObject
:
ExtensionsActions
.
ReloadAction
=
instantiationService
.
createInstance
(
ExtensionsActions
.
ReloadAction
,
false
);
const
gallery
=
aGalleryExtension
(
'
a
'
);
instantiationService
.
stubPromise
(
IExtensionGalleryService
,
'
query
'
,
aPage
(
gallery
));
const
paged
=
await
instantiationService
.
get
(
IExtensionsWorkbenchService
).
queryGallery
();
testObject
.
extension
=
paged
.
firstPage
[
0
];
assert
.
ok
(
!
testObject
.
enabled
);
installEvent
.
fire
({
identifier
:
gallery
.
identifier
,
gallery
});
didInstallEvent
.
fire
({
identifier
:
gallery
.
identifier
,
gallery
,
operation
:
InstallOperation
.
Install
,
local
:
aLocalExtension
(
'
a
'
,
{
...
gallery
,
...{
contributes
:
<
IExtensionContributions
>
{
localizations
:
[{
languageId
:
'
de
'
,
translations
:
[]
}]
}
}
},
gallery
)
});
assert
.
ok
(
!
testObject
.
enabled
);
});
test
(
'
Test ReloadAction when a localization extension is updated while running
'
,
async
()
=>
{
instantiationService
.
stubPromise
(
IExtensionService
,
'
getExtensions
'
,
[{
id
:
'
pub.a
'
,
version
:
'
1.0.1
'
,
extensionLocation
:
URI
.
file
(
'
pub.a
'
)
}]);
const
testObject
:
ExtensionsActions
.
ReloadAction
=
instantiationService
.
createInstance
(
ExtensionsActions
.
ReloadAction
,
false
);
const
local
=
aLocalExtension
(
'
a
'
,
{
version
:
'
1.0.1
'
,
contributes
:
<
IExtensionContributions
>
{
localizations
:
[{
languageId
:
'
de
'
,
translations
:
[]
}]
}
});
const
workbenchService
=
instantiationService
.
get
(
IExtensionsWorkbenchService
);
instantiationService
.
stubPromise
(
IExtensionManagementService
,
'
getInstalled
'
,
[
local
]);
const
extensions
=
await
workbenchService
.
queryLocal
();
testObject
.
extension
=
extensions
[
0
];
const
gallery
=
aGalleryExtension
(
'
a
'
,
{
uuid
:
local
.
identifier
.
id
,
version
:
'
1.0.2
'
});
installEvent
.
fire
({
identifier
:
gallery
.
identifier
,
gallery
});
didInstallEvent
.
fire
({
identifier
:
gallery
.
identifier
,
gallery
,
operation
:
InstallOperation
.
Install
,
local
:
aLocalExtension
(
'
a
'
,
{
...
gallery
,
...{
contributes
:
<
IExtensionContributions
>
{
localizations
:
[{
languageId
:
'
de
'
,
translations
:
[]
}]
}
}
},
gallery
)
});
assert
.
ok
(
!
testObject
.
enabled
);
});
test
(
`RecommendToFolderAction`
,
()
=>
{
test
(
`RecommendToFolderAction`
,
()
=>
{
// TODO: Implement test
// TODO: Implement test
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录