Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
bfb105b6
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bfb105b6
编写于
3月 26, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pull collection into its own file
上级
540232e3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
59 deletion
+57
-59
src/vs/workbench/contrib/terminal/common/environmentVariable.ts
.../workbench/contrib/terminal/common/environmentVariable.ts
+0
-5
src/vs/workbench/contrib/terminal/common/environmentVariableCollection.ts
.../contrib/terminal/common/environmentVariableCollection.ts
+55
-0
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
...nch/contrib/terminal/common/environmentVariableService.ts
+2
-54
未找到文件。
src/vs/workbench/contrib/terminal/common/environmentVariable.ts
浏览文件 @
bfb105b6
...
...
@@ -34,11 +34,6 @@ export interface IEnvironmentVariableCollection {
* Applies this collection to a process environment.
*/
applyToProcessEnvironment
(
env
:
IProcessEnvironment
):
void
;
/**
* Gets a serializable view of the collection.
*/
// serialize(): [string, IEnvironmentVariableMutator][];
}
/**
...
...
src/vs/workbench/contrib/terminal/common/environmentVariableCollection.ts
0 → 100644
浏览文件 @
bfb105b6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IEnvironmentVariableCollection
,
IEnvironmentVariableMutator
,
EnvironmentVariableMutatorType
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
IProcessEnvironment
}
from
'
vs/base/common/platform
'
;
export
class
EnvironmentVariableCollection
implements
IEnvironmentVariableCollection
{
readonly
entries
:
Map
<
string
,
IEnvironmentVariableMutator
>
;
constructor
(
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: Consider doing a full diff, just marking the environment as stale with no action available?
getNewAdditions
(
other
:
IEnvironmentVariableCollection
):
ReadonlyMap
<
string
,
IEnvironmentVariableMutator
>
|
undefined
{
const
result
=
new
Map
<
string
,
IEnvironmentVariableMutator
>
();
other
.
entries
.
forEach
((
newMutator
,
variable
)
=>
{
const
currentMutator
=
this
.
entries
.
get
(
variable
);
if
(
currentMutator
?.
type
!==
newMutator
.
type
||
currentMutator
.
value
!==
newMutator
.
value
)
{
result
.
set
(
variable
,
newMutator
);
}
});
return
result
.
size
===
0
?
undefined
:
result
;
}
applyToProcessEnvironment
(
env
:
IProcessEnvironment
):
void
{
this
.
entries
.
forEach
((
mutator
,
variable
)
=>
{
switch
(
mutator
.
type
)
{
case
EnvironmentVariableMutatorType
.
Append
:
env
[
variable
]
=
(
env
[
variable
]
||
''
)
+
mutator
.
value
;
break
;
case
EnvironmentVariableMutatorType
.
Prepend
:
env
[
variable
]
=
mutator
.
value
+
(
env
[
variable
]
||
''
);
break
;
case
EnvironmentVariableMutatorType
.
Replace
:
env
[
variable
]
=
mutator
.
value
;
break
;
}
});
}
}
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
浏览文件 @
bfb105b6
...
...
@@ -3,12 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IEnvironmentVariableService
,
IEnvironmentVariableCollection
,
IEnvironmentVariableMutator
,
EnvironmentVariableMutatorType
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
IEnvironmentVariableService
,
IEnvironmentVariableCollection
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
debounce
}
from
'
vs/base/common/decorators
'
;
import
{
IProcessEnvironment
}
from
'
vs/base/common/platform
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
EnvironmentVariableCollection
}
from
'
vs/workbench/contrib/terminal/common/environmentVariableCollection
'
;
const
ENVIRONMENT_VARIABLE_COLLECTIONS_KEY
=
'
terminal.integrated.environmentVariableCollections
'
;
...
...
@@ -22,54 +22,6 @@ interface ISerializableExtensionEnvironmentVariableCollection {
collection
:
ISerializableEnvironmentVariableCollection
}
export
class
EnvironmentVariableCollection
implements
IEnvironmentVariableCollection
{
readonly
entries
:
Map
<
string
,
IEnvironmentVariableMutator
>
;
constructor
(
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: Consider doing a full diff, just marking the environment as stale with no action available?
getNewAdditions
(
other
:
IEnvironmentVariableCollection
):
ReadonlyMap
<
string
,
IEnvironmentVariableMutator
>
|
undefined
{
const
result
=
new
Map
<
string
,
IEnvironmentVariableMutator
>
();
other
.
entries
.
forEach
((
newMutator
,
variable
)
=>
{
const
currentMutator
=
this
.
entries
.
get
(
variable
);
if
(
currentMutator
?.
type
!==
newMutator
.
type
||
currentMutator
.
value
!==
newMutator
.
value
)
{
result
.
set
(
variable
,
newMutator
);
}
});
return
result
.
size
===
0
?
undefined
:
result
;
}
applyToProcessEnvironment
(
env
:
IProcessEnvironment
):
void
{
this
.
entries
.
forEach
((
mutator
,
variable
)
=>
{
switch
(
mutator
.
type
)
{
case
EnvironmentVariableMutatorType
.
Append
:
env
[
variable
]
=
(
env
[
variable
]
||
''
)
+
mutator
.
value
;
break
;
case
EnvironmentVariableMutatorType
.
Prepend
:
env
[
variable
]
=
mutator
.
value
+
(
env
[
variable
]
||
''
);
break
;
case
EnvironmentVariableMutatorType
.
Replace
:
env
[
variable
]
=
mutator
.
value
;
break
;
}
});
}
}
/**
* Tracks and persists environment variable collections as defined by extensions.
*/
...
...
@@ -88,10 +40,7 @@ export class EnvironmentVariableService implements IEnvironmentVariableService {
)
{
const
serializedPersistedCollections
=
this
.
_storageService
.
get
(
ENVIRONMENT_VARIABLE_COLLECTIONS_KEY
,
StorageScope
.
WORKSPACE
);
if
(
serializedPersistedCollections
)
{
// TODO: Load in persisted collections
const
collectionsJson
:
ISerializableExtensionEnvironmentVariableCollection
[]
=
JSON
.
parse
(
serializedPersistedCollections
);
collectionsJson
.
forEach
(
c
=>
{
const
extCollection
=
new
EnvironmentVariableCollection
(
c
.
collection
.
variables
,
c
.
collection
.
values
,
c
.
collection
.
types
);
this
.
_collections
.
set
(
c
.
extensionIdentifier
,
extCollection
);
...
...
@@ -180,7 +129,6 @@ export class EnvironmentVariableService implements IEnvironmentVariableService {
}
}
function
serializeEnvironmentVariableCollection
(
collection
:
IEnvironmentVariableCollection
):
ISerializableEnvironmentVariableCollection
{
const
entries
=
[...
collection
.
entries
.
entries
()];
const
result
:
ISerializableEnvironmentVariableCollection
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录