Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b41b85d2
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,发现更多精彩内容 >>
提交
b41b85d2
编写于
3月 25, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Start building out env var service
上级
338d4298
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
110 addition
and
4 deletion
+110
-4
src/vs/workbench/api/browser/mainThreadTerminalService.ts
src/vs/workbench/api/browser/mainThreadTerminalService.ts
+6
-1
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+14
-0
src/vs/workbench/api/node/extHostTerminalService.ts
src/vs/workbench/api/node/extHostTerminalService.ts
+6
-3
src/vs/workbench/contrib/terminal/common/environmentVariable.ts
.../workbench/contrib/terminal/common/environmentVariable.ts
+30
-0
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
...nch/contrib/terminal/common/environmentVariableService.ts
+54
-0
未找到文件。
src/vs/workbench/api/browser/mainThreadTerminalService.ts
浏览文件 @
b41b85d2
...
...
@@ -5,7 +5,7 @@
import
{
DisposableStore
,
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IShellLaunchConfig
,
ITerminalProcessExtHostProxy
,
ISpawnExtHostProcessRequest
,
ITerminalDimensions
,
EXT_HOST_CREATION_DELAY
,
IAvailableShellsRequest
,
IDefaultShellAndArgsRequest
,
IStartExtensionTerminalRequest
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ExtHostContext
,
ExtHostTerminalServiceShape
,
MainThreadTerminalServiceShape
,
MainContext
,
IExtHostContext
,
IShellLaunchConfigDto
,
TerminalLaunchConfig
,
ITerminalDimensionsDto
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostContext
,
ExtHostTerminalServiceShape
,
MainThreadTerminalServiceShape
,
MainContext
,
IExtHostContext
,
IShellLaunchConfigDto
,
TerminalLaunchConfig
,
ITerminalDimensionsDto
,
IEnvironmentVariableCollectionDto
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/common/extHostCustomers
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
StopWatch
}
from
'
vs/base/common/stopwatch
'
;
...
...
@@ -346,6 +346,11 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
}
return
terminal
;
}
$updateEnvironmentVariableCollections
(
collections
:
IEnvironmentVariableCollectionDto
[]):
void
{
// TODO: Pass on to env var service
throw
new
Error
(
'
Method not implemented.
'
);
}
}
/**
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
b41b85d2
...
...
@@ -426,6 +426,19 @@ export interface TerminalLaunchConfig {
isExtensionTerminal
?:
boolean
;
}
export
enum
EnvironmentVariableMutatorType
{
Replace
=
1
,
Append
=
2
,
Prepend
=
3
}
export
interface
IEnvironmentVariableCollectionDto
{
extensionIdentifier
:
string
;
variables
:
string
[];
values
:
string
[];
types
:
EnvironmentVariableMutatorType
[];
}
export
interface
MainThreadTerminalServiceShape
extends
IDisposable
{
$createTerminal
(
config
:
TerminalLaunchConfig
):
Promise
<
{
id
:
number
,
name
:
string
;
}
>
;
$dispose
(
terminalId
:
number
):
void
;
...
...
@@ -436,6 +449,7 @@ export interface MainThreadTerminalServiceShape extends IDisposable {
$stopSendingDataEvents
():
void
;
$startHandlingLinks
():
void
;
$stopHandlingLinks
():
void
;
$updateEnvironmentVariableCollections
(
collections
:
IEnvironmentVariableCollectionDto
[]):
void
;
// Process
$sendProcessTitle
(
terminalId
:
number
,
title
:
string
):
void
;
...
...
src/vs/workbench/api/node/extHostTerminalService.ts
浏览文件 @
b41b85d2
...
...
@@ -26,6 +26,7 @@ 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
{
...
...
@@ -85,7 +86,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
private
_variableResolver
:
ExtHostVariableResolverService
|
undefined
;
private
_lastActiveWorkspace
:
IWorkspaceFolder
|
undefined
;
private
_environmentVariableCollection
:
vscode
.
EnvironmentVariableCollection
|
undefined
;
private
_environmentVariableCollection
:
Map
<
string
,
vscode
.
EnvironmentVariableCollection
>
=
new
Map
()
;
// TODO: Pull this from main side
private
_isWorkspaceShellAllowed
:
boolean
=
false
;
...
...
@@ -276,6 +277,8 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
}
public
getEnvironmentVariableCollection
(
extension
:
IExtensionDescription
,
persistent
?:
boolean
):
vscode
.
EnvironmentVariableCollection
{
dispose
(
this
.
_environmentVariableCollection
.
get
(
extension
.
identifier
.
value
));
let
collection
:
EnvironmentVariableCollection
;
if
(
persistent
)
{
// TODO: Persist when persistent is set
...
...
@@ -285,8 +288,8 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
collection
=
new
EnvironmentVariableCollection
();
}
collection
.
onDidChangeCollection
(()
=>
this
.
_updateEnvironmentVariableCollection
());
this
.
_environmentVariableCollection
=
collection
;
return
this
.
_environmentVariableC
ollection
;
this
.
_environmentVariableCollection
.
set
(
extension
.
identifier
.
value
,
collection
)
;
return
c
ollection
;
}
@
debounce
(
1000
)
...
...
src/vs/workbench/contrib/terminal/common/environmentVariable.ts
0 → 100644
浏览文件 @
b41b85d2
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
const
IEnvironmentVariableService
=
createDecorator
<
IEnvironmentVariableService
>
(
'
environmentVariableService
'
);
export
interface
IEnvironmentVariableMutator
{
readonly
value
:
string
;
readonly
type
:
'
replace
'
|
'
append
'
|
'
prepend
'
;
}
export
interface
IEnvironmentVariableCollection
{
readonly
entries
:
Map
<
string
,
IEnvironmentVariableMutator
>
;
}
/**
* Tracks and persists environment variable collections as defined by extensions.
*/
export
interface
IEnvironmentVariableService
{
/**
* Gets a single collection constructed by merging all collections into one.
*/
readonly
mergedCollection
:
IEnvironmentVariableCollection
;
set
(
extensionIdentifier
:
string
,
collection
:
IEnvironmentVariableCollection
):
void
;
delete
(
extensionIdentifier
:
string
):
void
;
}
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
0 → 100644
浏览文件 @
b41b85d2
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* 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
'
;
export
class
EnvironmentVariableCollection
implements
IEnvironmentVariableCollection
{
readonly
entries
:
Map
<
string
,
IEnvironmentVariableMutator
>
;
constructor
(
// TODO: Init entries via ctor if specified
)
{
this
.
entries
=
new
Map
();
}
}
/**
* Tracks and persists environment variable collections as defined by extensions.
*/
export
class
EnvironmentVariableService
implements
IEnvironmentVariableService
{
/**
* 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
_collections
:
Map
<
string
,
IEnvironmentVariableCollection
>
=
new
Map
();
// TODO: Load in persisted collections
// TODO: Fire an event when collections have changed that the terminal component can listen to
get
mergedCollection
():
IEnvironmentVariableCollection
{
if
(
!
this
.
_mergedCollection
)
{
this
.
_mergedCollection
=
this
.
_resolveMergedCollection
();
}
return
this
.
_mergedCollection
;
}
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
{
const
collection
=
new
EnvironmentVariableCollection
();
return
collection
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录