Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ed9e7241
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,发现更多精彩内容 >>
提交
ed9e7241
编写于
3月 25, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move single ext collection updates across
上级
8ee60554
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
128 addition
and
79 deletion
+128
-79
src/vs/workbench/api/browser/mainThreadTerminalService.ts
src/vs/workbench/api/browser/mainThreadTerminalService.ts
+11
-4
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-2
src/vs/workbench/api/common/extHostTerminalService.ts
src/vs/workbench/api/common/extHostTerminalService.ts
+57
-1
src/vs/workbench/api/node/extHostTerminalService.ts
src/vs/workbench/api/node/extHostTerminalService.ts
+8
-66
src/vs/workbench/contrib/terminal/common/environmentVariable.contribution.ts
...ntrib/terminal/common/environmentVariable.contribution.ts
+10
-0
src/vs/workbench/contrib/terminal/common/environmentVariable.ts
.../workbench/contrib/terminal/common/environmentVariable.ts
+4
-1
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
...nch/contrib/terminal/common/environmentVariableService.ts
+36
-5
src/vs/workbench/workbench.common.main.ts
src/vs/workbench/workbench.common.main.ts
+1
-0
未找到文件。
src/vs/workbench/api/browser/mainThreadTerminalService.ts
浏览文件 @
ed9e7241
...
...
@@ -13,6 +13,8 @@ import { ITerminalInstanceService, ITerminalService, ITerminalInstance, ITermina
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TerminalDataBufferer
}
from
'
vs/workbench/contrib/terminal/common/terminalDataBuffering
'
;
import
{
IEnvironmentVariableService
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
EnvironmentVariableCollection
}
from
'
vs/workbench/contrib/terminal/common/environmentVariableService
'
;
@
extHostNamedCustomer
(
MainContext
.
MainThreadTerminalService
)
export
class
MainThreadTerminalService
implements
MainThreadTerminalServiceShape
{
...
...
@@ -29,8 +31,9 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
extHostContext
:
IExtHostContext
,
@
ITerminalService
private
readonly
_terminalService
:
ITerminalService
,
@
ITerminalInstanceService
readonly
terminalInstanceService
:
ITerminalInstanceService
,
@
IRemoteAgentService
readonly
_remoteAgentService
:
IRemoteAgentService
,
@
IRemoteAgentService
private
readonly
_remoteAgentService
:
IRemoteAgentService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
IEnvironmentVariableService
private
readonly
_environmentVariableService
:
IEnvironmentVariableService
,
)
{
this
.
_proxy
=
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostTerminalService
);
this
.
_remoteAuthority
=
extHostContext
.
remoteAuthority
;
...
...
@@ -347,9 +350,13 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
return
terminal
;
}
$updateEnvironmentVariableCollections
(
collections
:
IEnvironmentVariableCollectionDto
[]):
void
{
// TODO: Pass on to env var service
throw
new
Error
(
'
Method not implemented.
'
);
$setEnvironmentVariableCollection
(
extensionIdentifier
:
string
,
collection
:
IEnvironmentVariableCollectionDto
|
undefined
):
void
{
if
(
collection
)
{
const
translatedCollection
=
new
EnvironmentVariableCollection
(
collection
.
variables
,
collection
.
values
,
collection
.
types
);
this
.
_environmentVariableService
.
set
(
extensionIdentifier
,
translatedCollection
);
}
else
{
this
.
_environmentVariableService
.
delete
(
extensionIdentifier
);
}
}
}
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
ed9e7241
...
...
@@ -428,7 +428,6 @@ export interface TerminalLaunchConfig {
}
export
interface
IEnvironmentVariableCollectionDto
{
extensionIdentifier
:
string
;
variables
:
string
[];
values
:
string
[];
types
:
EnvironmentVariableMutatorType
[];
...
...
@@ -444,7 +443,7 @@ export interface MainThreadTerminalServiceShape extends IDisposable {
$stopSendingDataEvents
():
void
;
$startHandlingLinks
():
void
;
$stopHandlingLinks
():
void
;
$
updateEnvironmentVariableCollections
(
collections
:
IEnvironmentVariableCollectionDto
[]
):
void
;
$
setEnvironmentVariableCollection
(
extensionIdentifier
:
string
,
collection
:
IEnvironmentVariableCollectionDto
|
undefined
):
void
;
// Process
$sendProcessTitle
(
terminalId
:
number
,
title
:
string
):
void
;
...
...
src/vs/workbench/api/common/extHostTerminalService.ts
浏览文件 @
ed9e7241
...
...
@@ -14,7 +14,7 @@ import { timeout } from 'vs/base/common/async';
import
{
IExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
import
{
TerminalDataBufferer
}
from
'
vs/workbench/contrib/terminal/common/terminalDataBuffering
'
;
import
{
IDisposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
as
VSCodeDisposable
}
from
'
./extHostTypes
'
;
import
{
Disposable
as
VSCodeDisposable
,
EnvironmentVariableMutatorType
}
from
'
./extHostTypes
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
export
interface
IExtHostTerminalService
extends
ExtHostTerminalServiceShape
{
...
...
@@ -640,6 +640,62 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
}
}
export
class
EnvironmentVariableMutator
implements
vscode
.
EnvironmentVariableMutator
{
constructor
(
public
value
:
string
,
public
type
:
vscode
.
EnvironmentVariableMutatorType
)
{
}
}
export
class
EnvironmentVariableCollection
implements
vscode
.
EnvironmentVariableCollection
{
private
_entries
:
Map
<
string
,
EnvironmentVariableMutator
>
=
new
Map
();
protected
readonly
_onDidChangeCollection
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
get
onDidChangeCollection
():
Event
<
void
>
{
return
this
.
_onDidChangeCollection
&&
this
.
_onDidChangeCollection
.
event
;
}
get
size
():
number
{
return
this
.
_entries
.
size
;
}
replace
(
variable
:
string
,
value
:
string
):
void
{
this
.
_entries
.
set
(
variable
,
new
EnvironmentVariableMutator
(
value
,
EnvironmentVariableMutatorType
.
Replace
));
this
.
_onDidChangeCollection
.
fire
();
}
append
(
variable
:
string
,
value
:
string
):
void
{
this
.
_entries
.
set
(
variable
,
new
EnvironmentVariableMutator
(
value
,
EnvironmentVariableMutatorType
.
Append
));
this
.
_onDidChangeCollection
.
fire
();
}
prepend
(
variable
:
string
,
value
:
string
):
void
{
this
.
_entries
.
set
(
variable
,
new
EnvironmentVariableMutator
(
value
,
EnvironmentVariableMutatorType
.
Prepend
));
this
.
_onDidChangeCollection
.
fire
();
}
get
(
variable
:
string
):
EnvironmentVariableMutator
|
undefined
{
return
this
.
_entries
.
get
(
variable
);
}
forEach
(
callback
:
(
variable
:
string
,
mutator
:
vscode
.
EnvironmentVariableMutator
,
collection
:
vscode
.
EnvironmentVariableCollection
)
=>
any
,
thisArg
?:
any
):
void
{
this
.
_entries
.
forEach
((
value
,
key
)
=>
callback
(
key
,
value
,
this
));
}
delete
(
variable
:
string
):
void
{
this
.
_entries
.
delete
(
variable
);
this
.
_onDidChangeCollection
.
fire
();
}
clear
():
void
{
this
.
_entries
.
clear
();
this
.
_onDidChangeCollection
.
fire
();
}
dispose
():
void
{
this
.
_entries
.
clear
();
this
.
_onDidChangeCollection
.
fire
();
}
}
export
class
WorkerExtHostTerminalService
extends
BaseExtHostTerminalService
{
public
createTerminal
(
name
?:
string
,
shellPath
?:
string
,
shellArgs
?:
string
[]
|
string
):
vscode
.
Terminal
{
throw
new
Error
(
'
Not implemented
'
);
...
...
src/vs/workbench/api/node/extHostTerminalService.ts
浏览文件 @
ed9e7241
...
...
@@ -20,67 +20,12 @@ import { ExtHostVariableResolverService } from 'vs/workbench/api/common/extHostD
import
{
ExtHostDocumentsAndEditors
,
IExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
getSystemShell
,
detectAvailableShells
}
from
'
vs/workbench/contrib/terminal/node/terminal
'
;
import
{
getMainProcessParentEnv
}
from
'
vs/workbench/contrib/terminal/node/terminalEnvironment
'
;
import
{
BaseExtHostTerminalService
,
ExtHostTerminal
}
from
'
vs/workbench/api/common/extHostTerminalService
'
;
import
{
BaseExtHostTerminalService
,
ExtHostTerminal
,
EnvironmentVariableCollection
}
from
'
vs/workbench/api/common/extHostTerminalService
'
;
import
{
IExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
EnvironmentVariableMutatorType
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
debounce
}
from
'
vs/base/common/decorators
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
class
EnvironmentVariableMutator
implements
vscode
.
EnvironmentVariableMutator
{
constructor
(
public
value
:
string
,
public
type
:
vscode
.
EnvironmentVariableMutatorType
)
{
}
}
class
EnvironmentVariableCollection
implements
vscode
.
EnvironmentVariableCollection
{
private
_entries
:
Map
<
string
,
EnvironmentVariableMutator
>
=
new
Map
();
protected
readonly
_onDidChangeCollection
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
get
onDidChangeCollection
():
Event
<
void
>
{
return
this
.
_onDidChangeCollection
&&
this
.
_onDidChangeCollection
.
event
;
}
replace
(
variable
:
string
,
value
:
string
):
void
{
this
.
_entries
.
set
(
variable
,
new
EnvironmentVariableMutator
(
value
,
EnvironmentVariableMutatorType
.
Replace
));
this
.
_onDidChangeCollection
.
fire
();
}
append
(
variable
:
string
,
value
:
string
):
void
{
this
.
_entries
.
set
(
variable
,
new
EnvironmentVariableMutator
(
value
,
EnvironmentVariableMutatorType
.
Append
));
this
.
_onDidChangeCollection
.
fire
();
}
prepend
(
variable
:
string
,
value
:
string
):
void
{
this
.
_entries
.
set
(
variable
,
new
EnvironmentVariableMutator
(
value
,
EnvironmentVariableMutatorType
.
Prepend
));
this
.
_onDidChangeCollection
.
fire
();
}
get
(
variable
:
string
):
EnvironmentVariableMutator
|
undefined
{
return
this
.
_entries
.
get
(
variable
);
}
forEach
(
callback
:
(
variable
:
string
,
mutator
:
vscode
.
EnvironmentVariableMutator
,
collection
:
vscode
.
EnvironmentVariableCollection
)
=>
any
,
thisArg
?:
any
):
void
{
this
.
_entries
.
forEach
((
value
,
key
)
=>
callback
(
key
,
value
,
this
));
}
delete
(
variable
:
string
):
void
{
this
.
_entries
.
delete
(
variable
);
this
.
_onDidChangeCollection
.
fire
();
}
clear
():
void
{
this
.
_entries
.
clear
();
this
.
_onDidChangeCollection
.
fire
();
}
dispose
():
void
{
this
.
_entries
.
clear
();
this
.
_onDidChangeCollection
.
fire
();
}
}
export
class
ExtHostTerminalService
extends
BaseExtHostTerminalService
{
private
_variableResolver
:
ExtHostVariableResolverService
|
undefined
;
...
...
@@ -287,21 +232,19 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
}
else
{
collection
=
new
EnvironmentVariableCollection
();
}
collection
.
onDidChangeCollection
(()
=>
this
.
_
updateEnvironmentVariableCollections
(
));
collection
.
onDidChangeCollection
(()
=>
this
.
_
syncEnvironmentVariableCollection
(
extension
.
identifier
.
value
,
collection
));
this
.
_environmentVariableCollection
.
set
(
extension
.
identifier
.
value
,
collection
);
return
collection
;
}
@
debounce
(
1000
)
private
_updateEnvironmentVariableCollections
():
void
{
const
collections
:
IEnvironmentVariableCollectionDto
[]
=
[];
this
.
_environmentVariableCollection
.
forEach
((
collection
,
extensionIdenfitier
)
=>
{
collections
.
push
(
this
.
_serializeEnvironmentVariableCollection
(
extensionIdenfitier
,
collection
));
});
this
.
_proxy
.
$updateEnvironmentVariableCollections
(
collections
);
private
_syncEnvironmentVariableCollection
(
extensionIdentifier
:
string
,
collection
:
EnvironmentVariableCollection
):
void
{
this
.
_proxy
.
$setEnvironmentVariableCollection
(
extensionIdentifier
,
this
.
_serializeEnvironmentVariableCollection
(
collection
));
}
private
_serializeEnvironmentVariableCollection
(
extensionIdentifier
:
string
,
collection
:
vscode
.
EnvironmentVariableCollection
):
IEnvironmentVariableCollectionDto
{
private
_serializeEnvironmentVariableCollection
(
collection
:
EnvironmentVariableCollection
):
IEnvironmentVariableCollectionDto
|
undefined
{
if
(
collection
.
size
===
0
)
{
return
undefined
;
}
const
variables
:
string
[]
=
[];
const
values
:
string
[]
=
[];
const
types
:
EnvironmentVariableMutatorType
[]
=
[];
...
...
@@ -311,7 +254,6 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
types
.
push
(
mutator
.
type
);
});
return
{
extensionIdentifier
,
variables
,
values
,
types
...
...
src/vs/workbench/contrib/terminal/common/environmentVariable.contribution.ts
0 → 100644
浏览文件 @
ed9e7241
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IEnvironmentVariableService
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
EnvironmentVariableService
}
from
'
vs/workbench/contrib/terminal/common/environmentVariableService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
registerSingleton
(
IEnvironmentVariableService
,
EnvironmentVariableService
,
true
);
src/vs/workbench/contrib/terminal/common/environmentVariable.ts
浏览文件 @
ed9e7241
...
...
@@ -19,13 +19,16 @@ export interface IEnvironmentVariableMutator {
}
export
interface
IEnvironmentVariableCollection
{
readonly
entries
:
Map
<
string
,
IEnvironmentVariableMutator
>
;
readonly
entries
:
ReadonlyMap
<
string
,
IEnvironmentVariableMutator
>
;
equals
(
other
:
IEnvironmentVariableCollection
):
boolean
;
}
/**
* Tracks and persists environment variable collections as defined by extensions.
*/
export
interface
IEnvironmentVariableService
{
_serviceBrand
:
undefined
;
/**
* Gets a single collection constructed by merging all collections into one.
*/
...
...
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
浏览文件 @
ed9e7241
...
...
@@ -3,15 +3,41 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IEnvironmentVariableService
,
IEnvironmentVariableCollection
,
IEnvironmentVariableMutator
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
IEnvironmentVariableService
,
IEnvironmentVariableCollection
,
IEnvironmentVariableMutator
,
EnvironmentVariableMutatorType
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
export
class
EnvironmentVariableCollection
implements
IEnvironmentVariableCollection
{
readonly
entries
:
Map
<
string
,
IEnvironmentVariableMutator
>
;
constructor
(
// TODO: Init entries via ctor if specified
variables
?:
string
[],
values
?:
string
[],
types
?:
EnvironmentVariableMutatorType
[]
)
{
this
.
entries
=
new
Map
();
if
(
variables
&&
values
&&
types
)
{
if
(
variables
.
length
!==
values
.
length
||
variables
.
length
!==
types
.
length
)
{
throw
new
Error
(
'
Cannot create environment collection from arrays of differing length
'
);
}
for
(
let
i
=
0
;
i
<
variables
.
length
;
i
++
)
{
this
.
entries
.
set
(
variables
[
i
],
{
value
:
values
[
i
],
type
:
types
[
i
]
});
}
}
}
// TODO: Implement diff method?
equals
(
other
:
IEnvironmentVariableCollection
):
boolean
{
if
(
this
.
entries
.
size
!==
other
.
entries
.
size
)
{
return
false
;
}
let
result
=
true
;
this
.
entries
.
forEach
((
mutator
,
variable
)
=>
{
const
otherMutator
=
other
.
entries
.
get
(
variable
);
if
(
otherMutator
!==
mutator
)
{
result
=
false
;
}
});
return
result
;
}
}
...
...
@@ -19,14 +45,21 @@ export class EnvironmentVariableCollection implements IEnvironmentVariableCollec
* Tracks and persists environment variable collections as defined by extensions.
*/
export
class
EnvironmentVariableService
implements
IEnvironmentVariableService
{
_serviceBrand
:
undefined
;
/**
* The merged collection, this is set to undefined when it needs to be resolved again and is
* evaluated lazily as needed.
*/
private
_mergedCollection
:
IEnvironmentVariableCollection
|
undefined
;
private
_mergedCollection
:
IEnvironmentVariableCollection
=
new
EnvironmentVariableCollection
()
;
private
_collections
:
Map
<
string
,
IEnvironmentVariableCollection
>
=
new
Map
();
// TODO: Debounce notifying of terminals about onDidChangeCollections
// TODO: Generate a summary of changes inside the terminal component as it needs to be done per-terminal compared to what it started with
protected
readonly
_onDidChangeCollections
=
new
Emitter
<
void
>
();
public
get
onDidChangeCollections
():
Event
<
void
>
{
return
this
.
_onDidChangeCollections
.
event
;
}
// TODO: Load in persisted collections
// TODO: Fire an event when collections have changed that the terminal component can listen to
...
...
@@ -39,12 +72,10 @@ export class EnvironmentVariableService implements IEnvironmentVariableService {
set
(
extensionIdentifier
:
string
,
collection
:
IEnvironmentVariableCollection
):
void
{
this
.
_collections
.
set
(
extensionIdentifier
,
collection
);
this
.
_mergedCollection
=
undefined
;
}
delete
(
extensionIdentifier
:
string
):
void
{
this
.
_collections
.
delete
(
extensionIdentifier
);
this
.
_mergedCollection
=
undefined
;
}
private
_resolveMergedCollection
():
IEnvironmentVariableCollection
{
...
...
src/vs/workbench/workbench.common.main.ts
浏览文件 @
ed9e7241
...
...
@@ -207,6 +207,7 @@ import 'vs/workbench/contrib/output/browser/output.contribution';
import
'
vs/workbench/contrib/output/browser/outputView
'
;
// Terminal
import
'
vs/workbench/contrib/terminal/browser/environmentVariable.contribution
'
;
import
'
vs/workbench/contrib/terminal/browser/terminal.contribution
'
;
import
'
vs/workbench/contrib/terminal/browser/terminalView
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录