Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
185cd700
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,发现更多精彩内容 >>
未验证
提交
185cd700
编写于
9月 17, 2021
作者:
M
Megan Rogge
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve empty workpsace handling
上级
152413e0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
16 addition
and
11 deletion
+16
-11
src/vs/workbench/contrib/terminal/browser/terminal.ts
src/vs/workbench/contrib/terminal/browser/terminal.ts
+2
-0
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
...vs/workbench/contrib/terminal/browser/terminalInstance.ts
+11
-10
src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts
...ch/contrib/terminal/test/browser/terminalInstance.test.ts
+3
-1
未找到文件。
src/vs/workbench/contrib/terminal/browser/terminal.ts
浏览文件 @
185cd700
...
...
@@ -572,6 +572,8 @@ export interface ITerminalInstance {
readonly
navigationMode
:
INavigationMode
|
undefined
;
description
:
string
|
undefined
;
userHome
:
string
|
undefined
/**
* Shows the environment information hover if the widget exists.
*/
...
...
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
浏览文件 @
185cd700
...
...
@@ -70,6 +70,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import
{
TerminalEditorInput
}
from
'
vs/workbench/contrib/terminal/browser/terminalEditorInput
'
;
import
{
isSafari
}
from
'
vs/base/browser/browser
'
;
import
{
ISeparator
,
template
}
from
'
vs/base/common/labels
'
;
import
{
IPathService
}
from
'
vs/workbench/services/path/common/pathService
'
;
// How long in milliseconds should an average frame take to render for a notification to appear
// which suggests the fallback DOM-based renderer
...
...
@@ -175,6 +176,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private
_staticTitle
?:
string
;
private
_workspaceFolder
?:
string
;
private
_labelComputer
?:
TerminalLabelComputer
;
private
_userHome
?:
string
;
target
?:
TerminalLocation
;
get
instanceId
():
number
{
return
this
.
_instanceId
;
}
...
...
@@ -231,6 +233,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
get
initialCwd
():
string
|
undefined
{
return
this
.
_initialCwd
;
}
get
capabilities
():
ProcessCapability
[]
{
return
this
.
_capabilities
;
}
get
description
():
string
|
undefined
{
return
this
.
_description
||
this
.
shellLaunchConfig
.
description
;
}
get
userHome
():
string
|
undefined
{
return
this
.
_userHome
;
}
// The onExit event is special in that it fires and is disposed after the terminal instance
// itself is disposed
private
readonly
_onExit
=
new
Emitter
<
number
|
undefined
>
();
...
...
@@ -278,6 +281,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
resource
:
URI
|
undefined
,
@
ITerminalInstanceService
private
readonly
_terminalInstanceService
:
ITerminalInstanceService
,
@
ITerminalProfileResolverService
private
readonly
_terminalProfileResolverService
:
ITerminalProfileResolverService
,
@
IPathService
private
readonly
_pathService
:
IPathService
,
@
IContextKeyService
private
readonly
_contextKeyService
:
IContextKeyService
,
@
IKeybindingService
private
readonly
_keybindingService
:
IKeybindingService
,
@
INotificationService
private
readonly
_notificationService
:
INotificationService
,
...
...
@@ -693,7 +697,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this
.
_xtermTypeAhead
=
this
.
_register
(
this
.
_instantiationService
.
createInstance
(
TypeAheadAddon
,
this
.
_processManager
,
this
.
_configHelper
));
this
.
_xterm
.
loadAddon
(
this
.
_xtermTypeAhead
);
this
.
_userHome
=
(
await
this
.
_pathService
.
userHome
()).
fsPath
;
return
xterm
;
}
...
...
@@ -1748,7 +1752,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if
(
this
.
_isVisible
)
{
// HACK: Force the renderer to unpause by simulating an IntersectionObserver event.
// This is to fix an issue where dragging the window to the top of the screen to
// This is to fix an issue where dragging the wind
p
ow to the top of the screen to
// maximize on Windows/Linux would fire an event saying that the terminal was not
// visible.
if
(
this
.
_xterm
.
getOption
(
'
rendererType
'
)
===
'
canvas
'
)
{
...
...
@@ -2284,7 +2288,7 @@ export class TerminalLabelComputer extends Disposable {
readonly
onDidChangeLabel
=
this
.
_onDidChangeLabel
.
event
;
constructor
(
private
readonly
_configHelper
:
TerminalConfigHelper
,
private
readonly
_instance
:
Pick
<
ITerminalInstance
,
'
shellLaunchConfig
'
|
'
cwd
'
|
'
initialCwd
'
|
'
processName
'
|
'
sequence
'
|
'
workspaceFolder
'
|
'
staticTitle
'
|
'
capabilities
'
|
'
title
'
|
'
description
'
>
,
private
readonly
_instance
:
Pick
<
ITerminalInstance
,
'
shellLaunchConfig
'
|
'
cwd
'
|
'
initialCwd
'
|
'
processName
'
|
'
sequence
'
|
'
userHome
'
|
'
workspaceFolder
'
|
'
staticTitle
'
|
'
capabilities
'
|
'
title
'
|
'
description
'
>
,
@
IWorkspaceContextService
private
readonly
_workspaceContextService
:
IWorkspaceContextService
)
{
super
();
...
...
@@ -2317,14 +2321,11 @@ export class TerminalLabelComputer extends Disposable {
if
(
this
.
_instance
.
staticTitle
&&
labelType
===
TerminalLabelType
.
Title
)
{
return
this
.
_instance
.
staticTitle
.
replace
(
/
[\n\r\t]
/g
,
''
)
||
templateProperties
.
process
?.
replace
(
/
[\n\r\t]
/g
,
''
)
||
''
;
}
const
detection
=
this
.
_instance
.
capabilities
.
includes
(
ProcessCapability
.
CwdDetection
);
const
zeroRootWorkspace
=
this
.
_workspaceContextService
.
getWorkspace
().
folders
.
length
===
0
&&
templateProperties
.
cwd
===
(
this
.
_instance
.
userHome
||
this
.
_configHelper
.
config
.
cwd
);
const
singleRootWorkspace
=
this
.
_workspaceContextService
.
getWorkspace
().
folders
.
length
===
1
&&
templateProperties
.
cwd
===
(
this
.
_configHelper
.
config
.
cwd
||
this
.
_workspaceContextService
.
getWorkspace
().
folders
[
0
]?.
uri
.
fsPath
);
templateProperties
.
cwdFolder
=
(
!
templateProperties
.
cwd
||
!
detection
||
zeroRootWorkspace
||
singleRootWorkspace
)
?
''
:
path
.
basename
(
templateProperties
.
cwd
);
if
(
!
templateProperties
.
cwd
||
!
this
.
_instance
.
capabilities
.
includes
(
ProcessCapability
.
CwdDetection
)
||
(
this
.
_workspaceContextService
.
getWorkspace
().
folders
.
length
<=
1
&&
(
templateProperties
.
cwd
===
(
this
.
_configHelper
.
config
.
cwd
||
(
this
.
_workspaceContextService
.
getWorkspace
().
folders
[
0
].
uri
.
fsPath
)))))
{
templateProperties
.
cwdFolder
=
''
;
}
else
if
(
templateProperties
.
cwd
&&
typeof
templateProperties
.
cwd
===
'
string
'
)
{
templateProperties
.
cwdFolder
=
path
.
basename
(
templateProperties
.
cwd
);
}
//Remove special characters that could mess with rendering
const
label
=
template
(
labelTemplate
,
(
templateProperties
as
unknown
)
as
{
[
key
:
string
]:
string
|
ISeparator
|
undefined
|
null
;
}).
replace
(
/
[\n\r\t]
/g
,
''
);
return
label
===
''
&&
labelType
===
TerminalLabelType
.
Title
?
(
this
.
_instance
.
processName
||
''
)
:
label
;
...
...
src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts
浏览文件 @
185cd700
...
...
@@ -17,7 +17,7 @@ import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/term
import
{
ITerminalInstance
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
basename
}
from
'
path
'
;
function
createInstance
(
partial
?:
Partial
<
ITerminalInstance
>
):
Pick
<
ITerminalInstance
,
'
shellLaunchConfig
'
|
'
cwd
'
|
'
initialCwd
'
|
'
processName
'
|
'
sequence
'
|
'
workspaceFolder
'
|
'
staticTitle
'
|
'
capabilities
'
|
'
title
'
|
'
description
'
>
{
function
createInstance
(
partial
?:
Partial
<
ITerminalInstance
>
):
Pick
<
ITerminalInstance
,
'
shellLaunchConfig
'
|
'
userHome
'
|
'
cwd
'
|
'
initialCwd
'
|
'
processName
'
|
'
sequence
'
|
'
workspaceFolder
'
|
'
staticTitle
'
|
'
capabilities
'
|
'
title
'
|
'
description
'
>
{
return
{
shellLaunchConfig
:
{},
cwd
:
'
cwd
'
,
...
...
@@ -29,6 +29,7 @@ function createInstance(partial?: Partial<ITerminalInstance>): Pick<ITerminalIns
capabilities
:
isWindows
?
[]
:
[
ProcessCapability
.
CwdDetection
],
title
:
''
,
description
:
''
,
userHome
:
undefined
,
...
partial
};
}
...
...
@@ -183,6 +184,7 @@ suite('Workbench - TerminalInstance', () => {
strictEqual
(
terminalLabelComputer
.
description
,
'
root2
'
);
}
});
//TODO: enable and test userHome
test
.
skip
(
'
should hide cwdFolder in empty workspaces when cwd matches the workspace
\'
s default cwd ($HOME or $HOMEDRIVE$HOMEPATH)
'
,
async
()
=>
{
configurationService
=
new
TestConfigurationService
({
terminal
:
{
integrated
:
{
tabs
:
{
separator
:
'
~
'
,
title
:
'
${process}${separator}${cwdFolder}
'
,
description
:
'
${cwdFolder}
'
}
},
cwd
:
ROOT_1
}
});
configHelper
=
new
TerminalConfigHelper
(
configurationService
,
null
!
,
null
!
,
null
!
,
null
!
,
null
!
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录