Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
257e976b
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,发现更多精彩内容 >>
未验证
提交
257e976b
编写于
7月 23, 2021
作者:
D
Daniel Imms
提交者:
GitHub
7月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #129241 from microsoft/tyriar/129240
Fix async in terminal ext host and custom pty impl terminals
上级
b9c87885
5b5766d7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
56 deletion
+67
-56
extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts
.../vscode-api-tests/src/singlefolder-tests/terminal.test.ts
+8
-8
src/vs/workbench/api/browser/mainThreadTerminalService.ts
src/vs/workbench/api/browser/mainThreadTerminalService.ts
+32
-37
src/vs/workbench/contrib/terminal/browser/terminal.ts
src/vs/workbench/contrib/terminal/browser/terminal.ts
+1
-1
src/vs/workbench/contrib/terminal/browser/terminalService.ts
src/vs/workbench/contrib/terminal/browser/terminalService.ts
+26
-10
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts
浏览文件 @
257e976b
...
...
@@ -669,7 +669,7 @@ import { assertNoRpc } from '../utils';
});
suite
(
'
environmentVariableCollection
'
,
()
=>
{
test
(
'
should have collection variables apply to terminals immediately after setting
'
,
async
(
done
)
=>
{
test
(
'
should have collection variables apply to terminals immediately after setting
'
,
(
done
)
=>
{
// Text to match on before passing the test
const
expectedText
=
[
'
~a2~
'
,
...
...
@@ -697,7 +697,7 @@ import { assertNoRpc } from '../utils';
collection
.
replace
(
'
A
'
,
'
~a2~
'
);
collection
.
append
(
'
B
'
,
'
~b2~
'
);
collection
.
prepend
(
'
C
'
,
'
~c2~
'
);
const
terminal
=
await
window
.
createTerminal
({
const
terminal
=
window
.
createTerminal
({
env
:
{
A
:
'
a1
'
,
B
:
'
b1
'
,
...
...
@@ -714,7 +714,7 @@ import { assertNoRpc } from '../utils';
terminal
.
sendText
(
'
echo $C
'
);
});
test
(
'
should have collection variables apply to environment variables that don
\'
t exist
'
,
async
(
done
)
=>
{
test
(
'
should have collection variables apply to environment variables that don
\'
t exist
'
,
(
done
)
=>
{
// Text to match on before passing the test
const
expectedText
=
[
'
~a2~
'
,
...
...
@@ -742,7 +742,7 @@ import { assertNoRpc } from '../utils';
collection
.
replace
(
'
A
'
,
'
~a2~
'
);
collection
.
append
(
'
B
'
,
'
~b2~
'
);
collection
.
prepend
(
'
C
'
,
'
~c2~
'
);
const
terminal
=
await
window
.
createTerminal
({
const
terminal
=
window
.
createTerminal
({
env
:
{
A
:
null
,
B
:
null
,
...
...
@@ -759,7 +759,7 @@ import { assertNoRpc } from '../utils';
terminal
.
sendText
(
'
echo $C
'
);
});
test
(
'
should respect clearing entries
'
,
async
(
done
)
=>
{
test
(
'
should respect clearing entries
'
,
(
done
)
=>
{
// Text to match on before passing the test
const
expectedText
=
[
'
~a1~
'
,
...
...
@@ -786,7 +786,7 @@ import { assertNoRpc } from '../utils';
collection
.
replace
(
'
A
'
,
'
~a2~
'
);
collection
.
replace
(
'
B
'
,
'
~a2~
'
);
collection
.
clear
();
const
terminal
=
await
window
.
createTerminal
({
const
terminal
=
window
.
createTerminal
({
env
:
{
A
:
'
~a1~
'
,
B
:
'
~b1~
'
...
...
@@ -800,7 +800,7 @@ import { assertNoRpc } from '../utils';
terminal
.
sendText
(
'
echo $B
'
);
});
test
(
'
should respect deleting entries
'
,
async
(
done
)
=>
{
test
(
'
should respect deleting entries
'
,
(
done
)
=>
{
// Text to match on before passing the test
const
expectedText
=
[
'
~a1~
'
,
...
...
@@ -827,7 +827,7 @@ import { assertNoRpc } from '../utils';
collection
.
replace
(
'
A
'
,
'
~a2~
'
);
collection
.
replace
(
'
B
'
,
'
~b2~
'
);
collection
.
delete
(
'
A
'
);
const
terminal
=
await
window
.
createTerminal
({
const
terminal
=
window
.
createTerminal
({
env
:
{
A
:
'
~a1~
'
,
B
:
'
~b2~
'
...
...
src/vs/workbench/api/browser/mainThreadTerminalService.ts
浏览文件 @
257e976b
...
...
@@ -30,7 +30,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
* to a numeric terminal id (an id generated on the renderer side)
* This comes in play only when dealing with terminals created on the extension host side
*/
private
_extHostTerminal
Ids
=
new
Map
<
string
,
number
>
();
private
_extHostTerminal
s
=
new
Map
<
string
,
Promise
<
ITerminalInstance
>
>
();
private
readonly
_toDispose
=
new
DisposableStore
();
private
readonly
_terminalProcessProxies
=
new
Map
<
number
,
ITerminalProcessExtHostProxy
>
();
private
readonly
_profileProviders
=
new
Map
<
string
,
IDisposable
>
();
...
...
@@ -109,19 +109,11 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this
.
_proxy
.
$acceptDefaultProfile
(...
await
Promise
.
all
([
defaultProfile
,
defaultAutomationProfile
]));
}
private
_getTerminalId
(
id
:
TerminalIdentifier
):
number
|
undefined
{
if
(
typeof
id
===
'
number
'
)
{
return
id
;
private
async
_getTerminalInstance
(
id
:
TerminalIdentifier
):
Promise
<
ITerminalInstance
|
undefined
>
{
if
(
typeof
id
===
'
string
'
)
{
return
this
.
_extHostTerminals
.
get
(
id
)
;
}
return
this
.
_extHostTerminalIds
.
get
(
id
);
}
private
_getTerminalInstance
(
id
:
TerminalIdentifier
):
ITerminalInstance
|
undefined
{
const
rendererId
=
this
.
_getTerminalId
(
id
);
if
(
typeof
rendererId
===
'
number
'
)
{
return
this
.
_terminalService
.
getInstanceFromId
(
rendererId
);
}
return
undefined
;
return
this
.
_terminalService
.
getInstanceFromId
(
id
);
}
public
async
$createTerminal
(
extHostTerminalId
:
string
,
launchConfig
:
TerminalLaunchConfig
):
Promise
<
void
>
{
...
...
@@ -141,29 +133,31 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
customPtyImplementation
:
launchConfig
.
isExtensionCustomPtyTerminal
?
(
id
,
cols
,
rows
)
=>
new
TerminalProcessExtHostProxy
(
id
,
cols
,
rows
,
this
.
_terminalService
)
:
undefined
,
extHostTerminalId
:
extHostTerminalId
,
extHostTerminalId
,
isFeatureTerminal
:
launchConfig
.
isFeatureTerminal
,
isExtensionOwnedTerminal
:
launchConfig
.
isExtensionOwnedTerminal
,
useShellEnvironment
:
launchConfig
.
useShellEnvironment
};
let
terminal
:
ITerminalInstance
|
undefined
;
if
(
launchConfig
.
isSplitTerminal
)
{
const
activeInstance
=
this
.
_terminalService
.
getInstanceHost
(
launchConfig
.
target
).
activeInstance
;
if
(
activeInstance
)
{
terminal
=
withNullAsUndefined
(
await
this
.
_terminalService
.
splitInstance
(
activeInstance
,
shellLaunchConfig
));
this
.
_extHostTerminals
.
set
(
extHostTerminalId
,
new
Promise
(
async
r
=>
{
let
terminal
:
ITerminalInstance
|
undefined
;
if
(
launchConfig
.
isSplitTerminal
)
{
const
activeInstance
=
this
.
_terminalService
.
getInstanceHost
(
launchConfig
.
target
).
activeInstance
;
if
(
activeInstance
)
{
terminal
=
withNullAsUndefined
(
await
this
.
_terminalService
.
splitInstance
(
activeInstance
,
shellLaunchConfig
));
}
}
}
if
(
!
terminal
)
{
terminal
=
await
this
.
_terminalService
.
createTerminal
({
config
:
shellLaunchConfig
,
target
:
launchConfig
.
target
}
);
}
this
.
_extHostTerminalIds
.
set
(
extHostTerminalId
,
terminal
.
instanceId
);
if
(
!
terminal
)
{
terminal
=
await
this
.
_terminalService
.
createTerminal
(
{
config
:
shellLaunchConfig
,
target
:
launchConfig
.
target
});
}
r
(
terminal
);
})
);
}
public
$show
(
id
:
TerminalIdentifier
,
preserveFocus
:
boolean
):
void
{
const
terminalInstance
=
this
.
_getTerminalInstance
(
id
);
public
async
$show
(
id
:
TerminalIdentifier
,
preserveFocus
:
boolean
):
Promise
<
void
>
{
const
terminalInstance
=
await
this
.
_getTerminalInstance
(
id
);
if
(
terminalInstance
)
{
this
.
_terminalService
.
setActiveInstance
(
terminalInstance
);
if
(
terminalInstance
.
target
===
TerminalLocation
.
Editor
)
{
...
...
@@ -174,20 +168,21 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
}
}
public
$hide
(
id
:
TerminalIdentifier
):
void
{
const
rendererId
=
this
.
_getTerminalId
(
id
);
const
i
nstance
=
this
.
_terminalService
.
activeInstance
;
if
(
instance
&&
instance
.
instanceId
===
rendererId
&&
i
nstance
.
target
!==
TerminalLocation
.
Editor
)
{
public
async
$hide
(
id
:
TerminalIdentifier
):
Promise
<
void
>
{
const
instanceToHide
=
await
this
.
_getTerminalInstance
(
id
);
const
activeI
nstance
=
this
.
_terminalService
.
activeInstance
;
if
(
activeInstance
&&
activeInstance
.
instanceId
===
instanceToHide
?.
instanceId
&&
activeI
nstance
.
target
!==
TerminalLocation
.
Editor
)
{
this
.
_terminalGroupService
.
hidePanel
();
}
}
public
$dispose
(
id
:
TerminalIdentifier
):
void
{
this
.
_getTerminalInstance
(
id
)?.
dispose
();
public
async
$dispose
(
id
:
TerminalIdentifier
):
Promise
<
void
>
{
(
await
this
.
_getTerminalInstance
(
id
)
)?.
dispose
();
}
public
$sendText
(
id
:
TerminalIdentifier
,
text
:
string
,
addNewLine
:
boolean
):
void
{
this
.
_getTerminalInstance
(
id
)?.
sendText
(
text
,
addNewLine
);
public
async
$sendText
(
id
:
TerminalIdentifier
,
text
:
string
,
addNewLine
:
boolean
):
Promise
<
void
>
{
const
instance
=
await
this
.
_getTerminalInstance
(
id
);
await
instance
?.
sendText
(
text
,
addNewLine
);
}
public
$startSendingDataEvents
():
void
{
...
...
src/vs/workbench/contrib/terminal/browser/terminal.ts
浏览文件 @
257e976b
...
...
@@ -618,7 +618,7 @@ export interface ITerminalInstance {
* required to run a command in the terminal. The character(s) added are \n or \r\n
* depending on the platform. This defaults to `true`.
*/
sendText
(
text
:
string
,
addNewLine
:
boolean
):
void
;
sendText
(
text
:
string
,
addNewLine
:
boolean
):
Promise
<
void
>
;
/** Scroll the terminal buffer down 1 line. */
scrollDownLine
():
void
;
...
...
src/vs/workbench/contrib/terminal/browser/terminalService.ts
浏览文件 @
257e976b
...
...
@@ -229,8 +229,9 @@ export class TerminalService implements ITerminalService {
lifecycleService
.
onWillShutdown
(
e
=>
this
.
_onWillShutdown
(
e
));
this
.
_configurationService
.
onDidChangeConfiguration
(
async
e
=>
{
if
(
e
.
affectsConfiguration
(
TerminalSettingPrefix
.
DefaultProfile
+
this
.
_getPlatformKey
())
||
e
.
affectsConfiguration
(
TerminalSettingPrefix
.
Profiles
+
this
.
_getPlatformKey
())
||
const
platformKey
=
await
this
.
_getPlatformKey
();
if
(
e
.
affectsConfiguration
(
TerminalSettingPrefix
.
DefaultProfile
+
platformKey
)
||
e
.
affectsConfiguration
(
TerminalSettingPrefix
.
Profiles
+
platformKey
)
||
e
.
affectsConfiguration
(
TerminalSettingId
.
UseWslProfiles
))
{
this
.
_refreshAvailableProfiles
();
}
...
...
@@ -957,7 +958,6 @@ export class TerminalService implements ITerminalService {
return
;
// Should never happen
}
else
if
(
'
id
'
in
value
.
profile
)
{
// extension contributed profile
console
.
log
(
value
.
profile
.
title
);
await
this
.
_configurationService
.
updateValue
(
`terminal.integrated.defaultProfile.
${
platformKey
}
`
,
value
.
profile
.
title
,
ConfigurationTarget
.
USER
);
this
.
_registerContributedProfile
(
value
.
profile
.
extensionIdentifier
,
value
.
profile
.
id
,
value
.
profile
.
title
,
{
...
...
@@ -1067,7 +1067,7 @@ export class TerminalService implements ITerminalService {
return
{
label
,
description
:
profile
.
path
,
profile
,
buttons
};
}
private
_convertProfileToShellLaunchConfig
(
shellLaunchConfigOrProfile
?:
IShellLaunchConfig
|
ITerminalProfile
|
IExtensionTerminalProfile
,
cwd
?:
string
|
URI
):
IShellLaunchConfig
{
private
_convertProfileToShellLaunchConfig
(
shellLaunchConfigOrProfile
?:
IShellLaunchConfig
|
ITerminalProfile
,
cwd
?:
string
|
URI
):
IShellLaunchConfig
{
if
(
shellLaunchConfigOrProfile
&&
'
profileName
'
in
shellLaunchConfigOrProfile
)
{
const
profile
=
shellLaunchConfigOrProfile
;
if
(
!
profile
.
path
)
{
...
...
@@ -1084,8 +1084,8 @@ export class TerminalService implements ITerminalService {
};
}
//
S
hell launch config was provided
if
(
shellLaunchConfigOrProfile
&&
'
cwd
'
in
shellLaunchConfigOrProfile
)
{
//
A s
hell launch config was provided
if
(
shellLaunchConfigOrProfile
)
{
if
(
cwd
)
{
shellLaunchConfigOrProfile
.
cwd
=
cwd
;
}
...
...
@@ -1109,11 +1109,27 @@ export class TerminalService implements ITerminalService {
}
async
createTerminal
(
options
?:
ICreateTerminalOptions
):
Promise
<
ITerminalInstance
>
{
const
shellLaunchConfig
=
this
.
_convertProfileToShellLaunchConfig
(
options
?.
config
||
options
);
const
config
=
options
?.
config
;
const
shellLaunchConfig
=
config
&&
'
extensionIdentifier
'
in
config
?
{}
:
this
.
_convertProfileToShellLaunchConfig
(
config
||
{});
const
contributedDefaultProfile
=
await
this
.
_getContributedDefaultProfile
(
shellLaunchConfig
);
if
(
contributedDefaultProfile
)
{
await
this
.
createContributedTerminalProfile
(
contributedDefaultProfile
.
extensionIdentifier
,
contributedDefaultProfile
.
id
,
{
isSplitTerminal
:
false
,
icon
:
contributedDefaultProfile
.
icon
});
// Get the contributed profile if it was provided
let
contributedProfile
=
config
&&
'
extensionIdentifier
'
in
config
?
config
:
undefined
;
// Get the default profile as a contributed profile if it exists
if
(
!
contributedProfile
&&
!
options
)
{
contributedProfile
=
await
this
.
_getContributedDefaultProfile
(
shellLaunchConfig
);
}
// Launch the contributed profile
if
(
contributedProfile
)
{
// TODO: createContributedTerminalProfile should be private if we want all terminal creation to go through createTerminal
await
this
.
createContributedTerminalProfile
(
contributedProfile
.
extensionIdentifier
,
contributedProfile
.
id
,
{
isSplitTerminal
:
false
,
icon
:
contributedProfile
.
icon
});
// TODO: The extension terminal may be created in the editor area
return
this
.
_terminalGroupService
.
instances
[
this
.
_terminalGroupService
.
instances
.
length
-
1
];
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录