Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
dab1430b
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,发现更多精彩内容 >>
提交
dab1430b
编写于
9月 25, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Shutdown exthost terminal processes gracefully
Fixes #107444
上级
b241d4cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
18 deletion
+29
-18
src/vs/workbench/api/common/extHostTerminalService.ts
src/vs/workbench/api/common/extHostTerminalService.ts
+25
-18
src/vs/workbench/services/extensions/common/extensionHostMain.ts
...workbench/services/extensions/common/extensionHostMain.ts
+4
-0
未找到文件。
src/vs/workbench/api/common/extHostTerminalService.ts
浏览文件 @
dab1430b
...
...
@@ -13,7 +13,7 @@ import { ITerminalChildProcess, ITerminalDimensions, EXT_HOST_CREATION_DELAY, IT
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
{
IDisposable
,
DisposableStore
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
as
VSCodeDisposable
,
EnvironmentVariableMutatorType
}
from
'
./extHostTypes
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ISerializableEnvironmentVariableCollection
}
from
'
vs/workbench/contrib/terminal/common/environmentVariable
'
;
...
...
@@ -22,7 +22,7 @@ import { NotSupportedError } from 'vs/base/common/errors';
import
{
serializeEnvironmentVariableCollection
}
from
'
vs/workbench/contrib/terminal/common/environmentVariableShared
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
export
interface
IExtHostTerminalService
extends
ExtHostTerminalServiceShape
{
export
interface
IExtHostTerminalService
extends
ExtHostTerminalServiceShape
,
IDisposable
{
readonly
_serviceBrand
:
undefined
;
...
...
@@ -306,14 +306,14 @@ interface ICachedLinkEntry {
link
:
vscode
.
TerminalLink
;
}
export
abstract
class
BaseExtHostTerminalService
implements
IExtHostTerminalService
,
ExtHostTerminalServiceShape
{
export
abstract
class
BaseExtHostTerminalService
extends
Disposable
implements
IExtHostTerminalService
,
ExtHostTerminalServiceShape
{
readonly
_serviceBrand
:
undefined
;
protected
_proxy
:
MainThreadTerminalServiceShape
;
protected
_activeTerminal
:
ExtHostTerminal
|
undefined
;
protected
_terminals
:
ExtHostTerminal
[]
=
[];
protected
_terminalProcesses
:
{
[
id
:
number
]:
ITerminalChildProcess
}
=
{}
;
protected
_terminalProcesses
:
Map
<
number
,
ITerminalChildProcess
>
=
new
Map
()
;
protected
_terminalProcessDisposables
:
{
[
id
:
number
]:
IDisposable
}
=
{};
protected
_extensionTerminalAwaitingStart
:
{
[
id
:
number
]:
{
initialDimensions
:
ITerminalDimensionsDto
|
undefined
}
|
undefined
}
=
{};
protected
_getTerminalPromises
:
{
[
id
:
number
]:
Promise
<
ExtHostTerminal
|
undefined
>
}
=
{};
...
...
@@ -342,6 +342,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
supportsProcesses
:
boolean
,
@
IExtHostRpcService
extHostRpc
:
IExtHostRpcService
)
{
super
();
this
.
_proxy
=
extHostRpc
.
getProxy
(
MainContext
.
MainThreadTerminalService
);
this
.
_bufferer
=
new
TerminalDataBufferer
(
this
.
_proxy
.
$sendProcessData
);
this
.
_onDidWriteTerminalData
=
new
Emitter
<
vscode
.
TerminalDataWriteEvent
>
({
...
...
@@ -349,6 +350,13 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
onLastListenerRemove
:
()
=>
this
.
_proxy
.
$stopSendingDataEvents
()
});
this
.
_proxy
.
$registerProcessSupport
(
supportsProcesses
);
this
.
_register
({
dispose
:
()
=>
{
for
(
const
[
_
,
terminalProcess
]
of
this
.
_terminalProcesses
)
{
terminalProcess
.
shutdown
(
true
);
}
}
});
}
public
abstract
createTerminal
(
name
?:
string
,
shellPath
?:
string
,
shellArgs
?:
string
[]
|
string
):
vscode
.
Terminal
;
...
...
@@ -421,11 +429,9 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
public
async
$acceptTerminalMaximumDimensions
(
id
:
number
,
cols
:
number
,
rows
:
number
):
Promise
<
void
>
{
await
this
.
_getTerminalByIdEventually
(
id
);
if
(
this
.
_terminalProcesses
[
id
])
{
// Extension pty terminal only - when virtual process resize fires it means that the
// terminal's maximum dimensions changed
this
.
_terminalProcesses
[
id
]?.
resize
(
cols
,
rows
);
}
// Extension pty terminal only - when virtual process resize fires it means that the
// terminal's maximum dimensions changed
this
.
_terminalProcesses
.
get
(
id
)?.
resize
(
cols
,
rows
);
}
public
async
$acceptTerminalTitleChange
(
id
:
number
,
name
:
string
):
Promise
<
void
>
{
...
...
@@ -497,8 +503,9 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
});
}
if
(
this
.
_terminalProcesses
[
id
])
{
(
this
.
_terminalProcesses
[
id
]
as
ExtHostPseudoterminal
).
startSendingEvents
(
initialDimensions
);
const
terminalProcess
=
this
.
_terminalProcesses
.
get
(
id
);
if
(
terminalProcess
)
{
(
terminalProcess
as
ExtHostPseudoterminal
).
startSendingEvents
(
initialDimensions
);
}
else
{
// Defer startSendingEvents call to when _setupExtHostProcessListeners is called
this
.
_extensionTerminalAwaitingStart
[
id
]
=
{
initialDimensions
};
...
...
@@ -520,7 +527,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
if
(
p
.
onProcessOverrideDimensions
)
{
disposables
.
add
(
p
.
onProcessOverrideDimensions
(
e
=>
this
.
_proxy
.
$sendOverrideDimensions
(
id
,
e
)));
}
this
.
_terminalProcesses
[
id
]
=
p
;
this
.
_terminalProcesses
.
set
(
id
,
p
)
;
const
awaitingStart
=
this
.
_extensionTerminalAwaitingStart
[
id
];
if
(
awaitingStart
&&
p
instanceof
ExtHostPseudoterminal
)
{
...
...
@@ -532,12 +539,12 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
}
public
$acceptProcessInput
(
id
:
number
,
data
:
string
):
void
{
this
.
_terminalProcesses
[
id
]
?.
input
(
data
);
this
.
_terminalProcesses
.
get
(
id
)
?.
input
(
data
);
}
public
$acceptProcessResize
(
id
:
number
,
cols
:
number
,
rows
:
number
):
void
{
try
{
this
.
_terminalProcesses
[
id
]
?.
resize
(
cols
,
rows
);
this
.
_terminalProcesses
.
get
(
id
)
?.
resize
(
cols
,
rows
);
}
catch
(
error
)
{
// We tried to write to a closed pipe / channel.
if
(
error
.
code
!==
'
EPIPE
'
&&
error
.
code
!==
'
ERR_IPC_CHANNEL_CLOSED
'
)
{
...
...
@@ -547,15 +554,15 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
}
public
$acceptProcessShutdown
(
id
:
number
,
immediate
:
boolean
):
void
{
this
.
_terminalProcesses
[
id
]
?.
shutdown
(
immediate
);
this
.
_terminalProcesses
.
get
(
id
)
?.
shutdown
(
immediate
);
}
public
$acceptProcessRequestInitialCwd
(
id
:
number
):
void
{
this
.
_terminalProcesses
[
id
]
?.
getInitialCwd
().
then
(
initialCwd
=>
this
.
_proxy
.
$sendProcessInitialCwd
(
id
,
initialCwd
));
this
.
_terminalProcesses
.
get
(
id
)
?.
getInitialCwd
().
then
(
initialCwd
=>
this
.
_proxy
.
$sendProcessInitialCwd
(
id
,
initialCwd
));
}
public
$acceptProcessRequestCwd
(
id
:
number
):
void
{
this
.
_terminalProcesses
[
id
]
?.
getCwd
().
then
(
cwd
=>
this
.
_proxy
.
$sendProcessCwd
(
id
,
cwd
));
this
.
_terminalProcesses
.
get
(
id
)
?.
getCwd
().
then
(
cwd
=>
this
.
_proxy
.
$sendProcessCwd
(
id
,
cwd
));
}
public
$acceptProcessRequestLatency
(
id
:
number
):
number
{
...
...
@@ -648,7 +655,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
this
.
_bufferer
.
stopBuffering
(
id
);
// Remove process reference
delete
this
.
_terminalProcesses
[
id
]
;
this
.
_terminalProcesses
.
delete
(
id
)
;
delete
this
.
_extensionTerminalAwaitingStart
[
id
];
// Clean up process disposables
...
...
src/vs/workbench/services/extensions/common/extensionHostMain.ts
浏览文件 @
dab1430b
...
...
@@ -21,6 +21,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
IExtHostRpcService
,
ExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
import
{
IURITransformerService
,
URITransformerService
}
from
'
vs/workbench/api/common/extHostUriTransformerService
'
;
import
{
IExtHostExtensionService
,
IHostUtils
}
from
'
vs/workbench/api/common/extHostExtensionService
'
;
import
{
IExtHostTerminalService
}
from
'
vs/workbench/api/common/extHostTerminalService
'
;
export
interface
IExitFn
{
(
code
?:
number
):
any
;
...
...
@@ -61,6 +62,9 @@ export class ExtensionHostMain {
// todo@joh
// ugly self - inject
const
terminalService
=
instaService
.
invokeFunction
(
accessor
=>
accessor
.
get
(
IExtHostTerminalService
));
this
.
_disposables
.
add
(
terminalService
);
const
logService
=
instaService
.
invokeFunction
(
accessor
=>
accessor
.
get
(
ILogService
));
this
.
_disposables
.
add
(
logService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录