Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
68f2ab61
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,发现更多精彩内容 >>
未验证
提交
68f2ab61
编写于
2月 07, 2020
作者:
A
Alex Ross
提交者:
GitHub
2月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Show specific task provider progress and allow providers to be canceled (#90236)
Part of #90087
上级
415c22d2
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
145 addition
and
48 deletion
+145
-48
src/vs/base/parts/quickinput/browser/quickInput.ts
src/vs/base/parts/quickinput/browser/quickInput.ts
+4
-0
src/vs/base/parts/quickinput/common/quickInput.ts
src/vs/base/parts/quickinput/common/quickInput.ts
+2
-0
src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
...vs/workbench/contrib/tasks/browser/abstractTaskService.ts
+80
-48
src/vs/workbench/contrib/tasks/browser/providerProgressManager.ts
...orkbench/contrib/tasks/browser/providerProgressManager.ts
+59
-0
未找到文件。
src/vs/base/parts/quickinput/browser/quickInput.ts
浏览文件 @
68f2ab61
...
...
@@ -575,6 +575,10 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
return
this
.
visible
?
this
.
ui
.
inputBox
.
hasFocus
()
:
false
;
}
public
focusOnInput
()
{
this
.
ui
.
inputBox
.
setFocus
();
}
onDidChangeSelection
=
this
.
onDidChangeSelectionEmitter
.
event
;
onDidTriggerItemButton
=
this
.
onDidTriggerItemButtonEmitter
.
event
;
...
...
src/vs/base/parts/quickinput/common/quickInput.ts
浏览文件 @
68f2ab61
...
...
@@ -209,6 +209,8 @@ export interface IQuickPick<T extends IQuickPickItem> extends IQuickInput {
validationMessage
:
string
|
undefined
;
inputHasFocus
():
boolean
;
focusOnInput
():
void
;
}
export
interface
IInputBox
extends
IQuickInput
{
...
...
src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
浏览文件 @
68f2ab61
...
...
@@ -34,7 +34,7 @@ import { IProgressService, IProgressOptions, ProgressLocation } from 'vs/platfor
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IHostService
}
from
'
vs/workbench/services/host/browser/host
'
;
import
{
INotificationService
,
IPromptChoice
}
from
'
vs/platform/notification/common/notification
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IDialogService
,
IConfirmationResult
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -63,7 +63,7 @@ import { getTemplates as getTaskTemplates } from 'vs/workbench/contrib/tasks/com
import
*
as
TaskConfig
from
'
../common/taskConfiguration
'
;
import
{
TerminalTaskSystem
}
from
'
./terminalTaskSystem
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
,
IQuickPick
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
TaskDefinitionRegistry
}
from
'
vs/workbench/contrib/tasks/common/taskDefinitionRegistry
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -80,6 +80,7 @@ import { IPreferencesService } from 'vs/workbench/services/preferences/common/pr
import
{
find
}
from
'
vs/base/common/arrays
'
;
import
{
CancellationToken
,
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
ProviderProgressMananger
}
from
'
vs/workbench/contrib/tasks/browser/providerProgressManager
'
;
const
QUICKOPEN_HISTORY_LIMIT_CONFIG
=
'
task.quickOpen.history
'
;
const
QUICKOPEN_DETAIL_CONFIG
=
'
task.quickOpen.detail
'
;
...
...
@@ -220,6 +221,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
private
_providers
:
Map
<
number
,
ITaskProvider
>
;
private
_providerTypes
:
Map
<
number
,
string
>
;
protected
_taskSystemInfos
:
Map
<
string
,
TaskSystemInfo
>
;
private
_providerProgressManager
:
ProviderProgressMananger
|
undefined
;
protected
_workspaceTasksPromise
?:
Promise
<
Map
<
string
,
WorkspaceFolderTaskResult
>>
;
protected
_areJsonTasksSupportedPromise
:
Promise
<
boolean
>
=
Promise
.
resolve
(
false
);
...
...
@@ -1347,36 +1349,26 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
protected
abstract
getTaskSystem
():
ITaskSystem
;
private
async
provideTasksWithWarning
(
provider
:
ITaskProvider
,
type
:
string
,
validTypes
:
IStringDictionary
<
boolean
>
):
Promise
<
TaskSet
>
{
private
async
provideTasksWithWarning
(
provider
:
ITaskProvider
,
type
:
string
,
validTypes
:
IStringDictionary
<
boolean
>
):
Promise
<
TaskSet
|
undefined
>
{
return
new
Promise
<
TaskSet
>
(
async
(
resolve
,
reject
)
=>
{
let
isDone
=
false
;
provider
.
provideTasks
(
validTypes
).
then
((
value
)
=>
{
let
disposable
:
IDisposable
|
undefined
;
const
providePromise
=
provider
.
provideTasks
(
validTypes
);
this
.
_providerProgressManager
?.
addProvider
(
type
,
providePromise
);
disposable
=
this
.
_providerProgressManager
?.
canceled
.
token
.
onCancellationRequested
(()
=>
{
if
(
!
isDone
)
{
resolve
();
}
});
providePromise
.
then
((
value
)
=>
{
isDone
=
true
;
disposable
?.
dispose
();
resolve
(
value
);
},
(
e
)
=>
{
isDone
=
true
;
disposable
?.
dispose
();
reject
(
e
);
});
let
settingValue
:
boolean
|
string
[]
=
this
.
configurationService
.
getValue
(
'
task.slowProviderWarning
'
);
if
((
settingValue
===
true
)
||
(
Types
.
isStringArray
(
settingValue
)
&&
(
settingValue
.
indexOf
(
type
)
<
0
)))
{
setTimeout
(()
=>
{
if
(
!
isDone
)
{
const
settings
:
IPromptChoice
=
{
label
:
nls
.
localize
(
'
TaskSystem.slowProvider.settings
'
,
"
Settings
"
),
run
:
()
=>
this
.
preferencesService
.
openSettings
(
false
,
undefined
)
};
const
disableAll
:
IPromptChoice
=
{
label
:
nls
.
localize
(
'
TaskSystem.slowProvider.disableAll
'
,
"
Disable All
"
),
run
:
()
=>
this
.
configurationService
.
updateValue
(
'
task.autoDetect
'
,
'
off
'
)
};
const
dontShow
:
IPromptChoice
=
{
label
:
nls
.
localize
(
'
TaskSystem.slowProvider.dontShow
'
,
"
Don't warn again for {0} tasks
"
,
type
),
run
:
()
=>
{
if
(
!
Types
.
isStringArray
(
settingValue
))
{
settingValue
=
[];
}
settingValue
.
push
(
type
);
return
this
.
configurationService
.
updateValue
(
'
task.slowProviderWarning
'
,
settingValue
);
}
};
this
.
notificationService
.
prompt
(
Severity
.
Warning
,
nls
.
localize
(
'
TaskSystem.slowProvider
'
,
"
The {0} task provider is slow. The extension that provides {0} tasks may provide a setting to disable it, or you can disable all tasks providers
"
,
type
),
[
settings
,
disableAll
,
dontShow
]);
}
},
4000
);
}
});
}
...
...
@@ -1386,10 +1378,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
TaskDefinitionRegistry
.
all
().
forEach
(
definition
=>
validTypes
[
definition
.
taskType
]
=
true
);
validTypes
[
'
shell
'
]
=
true
;
validTypes
[
'
process
'
]
=
true
;
this
.
_providerProgressManager
=
new
ProviderProgressMananger
();
return
new
Promise
<
TaskSet
[]
>
(
resolve
=>
{
let
result
:
TaskSet
[]
=
[];
let
counter
:
number
=
0
;
let
done
=
(
value
:
TaskSet
)
=>
{
let
done
=
(
value
:
TaskSet
|
undefined
)
=>
{
if
(
value
)
{
result
.
push
(
value
);
}
...
...
@@ -2085,10 +2078,13 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
return
entries
;
});
return
this
.
quickInputService
.
pick
(
pickEntries
,
{
placeHolder
,
matchOnDescription
:
true
,
onDidTriggerItemButton
:
context
=>
{
const
picker
:
IQuickPick
<
TaskQuickPickEntry
>
=
this
.
quickInputService
.
createQuickPick
();
picker
.
placeholder
=
placeHolder
;
picker
.
matchOnDescription
=
true
;
picker
.
ignoreFocusOut
=
true
;
picker
.
onDidTriggerItemButton
(
context
=>
{
let
task
=
context
.
item
.
task
;
this
.
quickInputService
.
cancel
();
if
(
ContributedTask
.
is
(
task
))
{
...
...
@@ -2096,8 +2092,42 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
else
if
(
CustomTask
.
is
(
task
))
{
this
.
openConfig
(
task
);
}
});
picker
.
busy
=
true
;
const
progressManager
=
this
.
_providerProgressManager
;
const
progressTimeout
=
setTimeout
(()
=>
{
if
(
progressManager
)
{
progressManager
.
showProgress
=
(
stillProviding
)
=>
{
let
message
=
undefined
;
if
(
stillProviding
.
length
>
0
)
{
message
=
nls
.
localize
(
'
pickProgressManager.description
'
,
'
Getting tasks from extensions. {0} extension(s) remaining: {1}
'
,
stillProviding
.
length
,
stillProviding
.
join
(
'
,
'
));
}
picker
.
description
=
message
;
};
progressManager
.
addOnDoneListener
(()
=>
{
picker
.
focusOnInput
();
picker
.
customButton
=
false
;
});
if
(
!
progressManager
.
isDone
)
{
picker
.
customLabel
=
nls
.
localize
(
'
taskQuickPick.cancel
'
,
"
Cancel Remaining Extensions
"
);
picker
.
onDidCustom
(()
=>
{
this
.
_providerProgressManager
?.
cancel
();
});
picker
.
customButton
=
true
;
}
},
cancellationToken
).
then
(
async
(
selection
)
=>
{
}
},
1000
);
pickEntries
.
then
(
entries
=>
{
clearTimeout
(
progressTimeout
);
progressManager
?.
dispose
();
picker
.
busy
=
false
;
picker
.
items
=
entries
;
});
picker
.
show
();
return
new
Promise
<
TaskQuickPickEntry
|
undefined
|
null
>
(
resolve
=>
{
this
.
_register
(
picker
.
onDidAccept
(
async
()
=>
{
let
selection
=
picker
.
selectedItems
?
picker
.
selectedItems
[
0
]
:
undefined
;
if
(
cancellationToken
.
isCancellationRequested
)
{
// canceled when there's only one task
const
task
=
(
await
pickEntries
)[
0
];
...
...
@@ -2105,10 +2135,12 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
selection
=
<
TaskQuickPickEntry
>
task
;
}
}
picker
.
dispose
();
if
(
!
selection
)
{
return
;
resolve
()
;
}
return
selection
;
resolve
(
selection
);
}));
});
}
...
...
src/vs/workbench/contrib/tasks/browser/providerProgressManager.ts
0 → 100644
浏览文件 @
68f2ab61
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
TaskSet
}
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
export
class
ProviderProgressMananger
extends
Disposable
{
private
_onProviderComplete
:
Emitter
<
string
>
=
new
Emitter
();
private
_stillProviding
:
Set
<
string
>
=
new
Set
();
private
_onDone
:
Emitter
<
void
>
=
new
Emitter
();
private
_isDone
:
boolean
=
false
;
private
_showProgress
:
((
remaining
:
string
[])
=>
void
)
|
undefined
;
public
canceled
:
CancellationTokenSource
=
new
CancellationTokenSource
();
constructor
()
{
super
();
this
.
_register
(
this
.
_onProviderComplete
.
event
(
taskType
=>
{
this
.
_stillProviding
.
delete
(
taskType
);
if
(
this
.
_stillProviding
.
size
===
0
)
{
this
.
_isDone
=
true
;
this
.
_onDone
.
fire
();
}
if
(
this
.
_showProgress
)
{
this
.
_showProgress
(
Array
.
from
(
this
.
_stillProviding
));
}
}));
}
public
addProvider
(
taskType
:
string
,
provider
:
Promise
<
TaskSet
>
)
{
this
.
_stillProviding
.
add
(
taskType
);
provider
.
then
(()
=>
this
.
_onProviderComplete
.
fire
(
taskType
));
}
public
addOnDoneListener
(
onDoneListener
:
()
=>
void
)
{
this
.
_register
(
this
.
_onDone
.
event
(
onDoneListener
));
}
set
showProgress
(
progressDisplayFunction
:
(
remaining
:
string
[])
=>
void
)
{
this
.
_showProgress
=
progressDisplayFunction
;
this
.
_showProgress
(
Array
.
from
(
this
.
_stillProviding
));
}
get
isDone
():
boolean
{
return
this
.
_isDone
;
}
public
cancel
()
{
this
.
_isDone
=
true
;
if
(
this
.
_showProgress
)
{
this
.
_showProgress
([]);
}
this
.
_onDone
.
fire
();
this
.
canceled
.
cancel
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录