Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
70d9a5c1
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,发现更多精彩内容 >>
提交
70d9a5c1
编写于
3月 07, 2017
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove a lot of duplication and simplify config helper further
上级
f99e126b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
35 addition
and
162 deletion
+35
-162
src/vs/workbench/parts/debug/electron-browser/terminalSupport.ts
...workbench/parts/debug/electron-browser/terminalSupport.ts
+1
-1
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+1
-7
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+1
-1
src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts
...h/parts/terminal/electron-browser/terminalConfigHelper.ts
+11
-39
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+7
-7
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
...orkbench/parts/terminal/electron-browser/terminalPanel.ts
+2
-2
src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts
...rminal/test/electron-browser/terminalConfigHelper.test.ts
+0
-95
src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts
...s/terminal/test/electron-browser/terminalInstance.test.ts
+12
-10
未找到文件。
src/vs/workbench/parts/debug/electron-browser/terminalSupport.ts
浏览文件 @
70d9a5c1
...
...
@@ -57,7 +57,7 @@ export class TerminalSupport {
// get the shell configuration for the current platform
let
shell
:
string
;
const
shell_config
=
configurationService
.
getConfiguration
<
ITerminalConfiguration
>
().
terminal
.
integrated
.
shell
;
const
shell_config
=
configurationService
.
getConfiguration
<
ITerminalConfiguration
>
().
shell
;
if
(
platform
.
isWindows
)
{
shell
=
shell_config
.
windows
;
}
else
if
(
platform
.
isLinux
)
{
...
...
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
70d9a5c1
...
...
@@ -61,15 +61,9 @@ export interface ITerminalConfiguration {
}
export
interface
ITerminalConfigHelper
{
config
:
ITerminalConfiguration
;
getTheme
(
baseThemeId
:
string
):
string
[];
getFont
():
ITerminalFont
;
getFontLigaturesEnabled
():
boolean
;
getCursorBlink
():
boolean
;
getRightClickCopyPaste
():
boolean
;
getCommandsToSkipShell
():
string
[];
getScrollback
():
number
;
getCwd
():
string
;
getConfirmOnExit
():
boolean
;
}
export
interface
ITerminalFont
{
...
...
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
70d9a5c1
...
...
@@ -64,7 +64,7 @@ export abstract class TerminalService implements ITerminalService {
public
abstract
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
;
private
_onWillShutdown
():
boolean
{
if
(
!
this
.
configHelper
.
getConfirmOnExit
()
)
{
if
(
!
this
.
configHelper
.
config
.
confirmOnExit
)
{
// Don't veto if configured to skip confirmation
return
false
;
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts
浏览文件 @
70d9a5c1
...
...
@@ -8,6 +8,12 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import
{
ITerminalConfiguration
,
ITerminalConfigHelper
,
ITerminalFont
,
IShellLaunchConfig
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
Platform
}
from
'
vs/base/common/platform
'
;
interface
IFullTerminalConfiguration
{
terminal
:
{
integrated
:
ITerminalConfiguration
;
};
}
const
DEFAULT_LINE_HEIGHT
=
1.2
;
const
DEFAULT_ANSI_COLORS
=
{
...
...
@@ -81,7 +87,9 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
@
IConfigurationService
private
_configurationService
:
IConfigurationService
)
{
}
private
get
_config
():
ITerminalConfiguration
{
return
this
.
_configurationService
.
getConfiguration
<
ITerminalConfiguration
>
(
'
terminal.integrated
'
);
}
public
get
config
():
ITerminalConfiguration
{
return
this
.
_configurationService
.
getConfiguration
<
IFullTerminalConfiguration
>
().
terminal
.
integrated
;
}
public
getTheme
(
baseThemeId
:
string
):
string
[]
{
return
DEFAULT_ANSI_COLORS
[
baseThemeId
];
...
...
@@ -119,7 +127,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
public
getFont
():
ITerminalFont
{
const
config
=
this
.
_configurationService
.
getConfiguration
();
const
editorConfig
=
(
<
IEditorConfiguration
>
config
).
editor
;
const
terminalConfig
=
this
.
_
config
;
const
terminalConfig
=
this
.
config
;
const
fontFamily
=
terminalConfig
.
fontFamily
||
editorConfig
.
fontFamily
;
let
fontSize
=
this
.
_toInteger
(
terminalConfig
.
fontSize
,
0
);
...
...
@@ -134,28 +142,8 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
return
this
.
_measureFont
(
fontFamily
,
fontSize
,
lineHeight
);
}
public
getFontLigaturesEnabled
():
boolean
{
return
this
.
_config
.
fontLigatures
;
}
public
getCursorBlink
():
boolean
{
return
this
.
_config
.
cursorBlinking
;
}
public
getCursorStyle
():
string
{
return
this
.
_config
.
cursorStyle
;
}
public
getRightClickCopyPaste
():
boolean
{
return
this
.
_config
.
rightClickCopyPaste
;
}
public
getCommandsToSkipShell
():
string
[]
{
return
this
.
_config
.
commandsToSkipShell
;
}
public
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
):
IShellLaunchConfig
{
const
config
=
this
.
_
config
;
const
config
=
this
.
config
;
shell
.
executable
=
''
;
shell
.
args
=
[];
...
...
@@ -174,22 +162,6 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
return
shell
;
}
public
getScrollback
():
number
{
return
this
.
_config
.
scrollback
;
}
public
isSetLocaleVariables
():
boolean
{
return
this
.
_config
.
setLocaleVariables
;
}
public
getCwd
():
string
{
return
this
.
_config
.
cwd
;
}
public
getConfirmOnExit
():
boolean
{
return
this
.
_config
.
confirmOnExit
;
}
private
_toInteger
(
source
:
any
,
minimum
?:
number
):
number
{
let
r
=
parseInt
(
source
,
10
);
if
(
isNaN
(
r
))
{
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
70d9a5c1
...
...
@@ -171,7 +171,7 @@ export class TerminalInstance implements ITerminalInstance {
*/
protected
_createXterm
():
void
{
this
.
_xterm
=
xterm
({
scrollback
:
this
.
_configHelper
.
getScrollback
()
scrollback
:
this
.
_configHelper
.
config
.
scrollback
});
this
.
_process
.
on
(
'
message
'
,
(
message
)
=>
this
.
_sendPtyDataToXterm
(
message
));
this
.
_xterm
.
on
(
'
data
'
,
(
data
)
=>
{
...
...
@@ -414,7 +414,7 @@ export class TerminalInstance implements ITerminalInstance {
// TODO: Handle non-existent customCwd
if
(
!
shell
.
ignoreConfigurationCwd
)
{
// Evaluate custom cwd first
const
customCwd
=
this
.
_configHelper
.
getCwd
()
;
const
customCwd
=
this
.
_configHelper
.
config
.
cwd
;
if
(
customCwd
)
{
if
(
path
.
isAbsolute
(
customCwd
))
{
cwd
=
customCwd
;
...
...
@@ -433,7 +433,7 @@ export class TerminalInstance implements ITerminalInstance {
}
protected
_createProcess
(
workspace
:
IWorkspace
,
shell
:
IShellLaunchConfig
):
void
{
const
locale
=
this
.
_configHelper
.
isSetLocaleVariables
()
?
platform
.
locale
:
undefined
;
const
locale
=
this
.
_configHelper
.
config
.
setLocaleVariables
?
platform
.
locale
:
undefined
;
if
(
!
shell
.
executable
)
{
this
.
_configHelper
.
mergeDefaultShellPathAndArgs
(
shell
);
}
...
...
@@ -646,10 +646,10 @@ export class TerminalInstance implements ITerminalInstance {
}
public
updateConfig
():
void
{
this
.
_setCursorBlink
(
this
.
_configHelper
.
getCursorBlink
()
);
this
.
_setCursorStyle
(
this
.
_configHelper
.
getCursorStyle
()
);
this
.
_setCommandsToSkipShell
(
this
.
_configHelper
.
getCommandsToSkipShell
()
);
this
.
_setScrollback
(
this
.
_configHelper
.
getScrollback
()
);
this
.
_setCursorBlink
(
this
.
_configHelper
.
config
.
cursorBlinking
);
this
.
_setCursorStyle
(
this
.
_configHelper
.
config
.
cursorStyle
);
this
.
_setCommandsToSkipShell
(
this
.
_configHelper
.
config
.
commandsToSkipShell
);
this
.
_setScrollback
(
this
.
_configHelper
.
config
.
scrollback
);
}
private
_setCursorBlink
(
blink
:
boolean
):
void
{
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
浏览文件 @
70d9a5c1
...
...
@@ -151,7 +151,7 @@ export class TerminalPanel extends Panel {
// occurs on the selection itself.
this
.
_terminalService
.
getActiveInstance
().
focus
();
}
else
if
(
event
.
which
===
3
)
{
if
(
this
.
_terminalService
.
configHelper
.
getRightClickCopyPaste
()
)
{
if
(
this
.
_terminalService
.
configHelper
.
config
.
rightClickCopyPaste
)
{
let
terminal
=
this
.
_terminalService
.
getActiveInstance
();
if
(
terminal
.
hasSelection
())
{
terminal
.
copySelection
();
...
...
@@ -238,7 +238,7 @@ export class TerminalPanel extends Panel {
return
;
}
let
newFont
=
this
.
_terminalService
.
configHelper
.
getFont
();
DOM
.
toggleClass
(
this
.
_parentDomElement
,
'
enable-ligatures
'
,
this
.
_terminalService
.
configHelper
.
getFontLigaturesEnabled
()
);
DOM
.
toggleClass
(
this
.
_parentDomElement
,
'
enable-ligatures
'
,
this
.
_terminalService
.
configHelper
.
config
.
fontLigatures
);
if
(
!
this
.
_font
||
this
.
_fontsDiffer
(
this
.
_font
,
newFont
))
{
this
.
_fontStyleElement
.
innerHTML
=
'
.monaco-workbench .panel.integrated-terminal .xterm {
'
+
`font-family:
${
newFont
.
fontFamily
}
;`
+
...
...
src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts
浏览文件 @
70d9a5c1
...
...
@@ -281,99 +281,4 @@ suite('Workbench - TerminalConfigHelper', () => {
'
#e5e5e5
'
],
'
The dark terminal theme should be selected when a vs-dark theme is active
'
);
});
test
(
'
TerminalConfigHelper - getFontLigaturesEnabled
'
,
function
()
{
let
configurationService
:
IConfigurationService
;
let
configHelper
:
TerminalConfigHelper
;
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
fontLigatures
:
true
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
equal
(
configHelper
.
getFontLigaturesEnabled
(),
true
,
'
terminal.integrated.fontLigatures should be true
'
);
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
fontLigatures
:
false
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
equal
(
configHelper
.
getFontLigaturesEnabled
(),
false
,
'
terminal.integrated.fontLigatures should be false
'
);
});
test
(
'
TerminalConfigHelper - getCursorBlink
'
,
function
()
{
let
configurationService
:
IConfigurationService
;
let
configHelper
:
TerminalConfigHelper
;
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
cursorBlinking
:
true
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
equal
(
configHelper
.
getCursorBlink
(),
true
,
'
terminal.integrated.cursorBlinking should be true
'
);
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
cursorBlinking
:
false
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
equal
(
configHelper
.
getCursorBlink
(),
false
,
'
terminal.integrated.cursorBlinking should be false
'
);
});
test
(
'
TerminalConfigHelper - isSetLocaleVariables
'
,
function
()
{
let
configurationService
:
IConfigurationService
;
let
configHelper
:
TerminalConfigHelper
;
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
setLocaleVariables
:
true
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
equal
(
configHelper
.
isSetLocaleVariables
(),
true
,
'
terminal.integrated.setLocaleVariables should be true
'
);
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
setLocaleVariables
:
false
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
equal
(
configHelper
.
isSetLocaleVariables
(),
false
,
'
terminal.integrated.setLocaleVariables should be false
'
);
});
test
(
'
TerminalConfigHelper - getCommandsToSkipShell
'
,
function
()
{
let
configurationService
:
IConfigurationService
;
let
configHelper
:
TerminalConfigHelper
;
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
commandsToSkipShell
:
[]
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
deepEqual
(
configHelper
.
getCommandsToSkipShell
(),
[],
'
terminal.integrated.commandsToSkipShell should be []
'
);
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
commandsToSkipShell
:
[
'
foo
'
]
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
deepEqual
(
configHelper
.
getCommandsToSkipShell
(),
[
'
foo
'
],
'
terminal.integrated.commandsToSkipShell should be [
\'
foo
\'
]
'
);
});
test
(
'
TerminalConfigHelper - getScrollback
'
,
function
()
{
let
configurationService
:
IConfigurationService
;
let
configHelper
:
TerminalConfigHelper
;
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
scrollback
:
10
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
deepEqual
(
configHelper
.
getScrollback
(),
10
,
'
terminal.integrated.scrollback should be 10
'
);
configurationService
=
new
MockConfigurationService
({
terminal
:
{
integrated
:
{
scrollback
:
20
}
}
});
configHelper
=
new
TerminalConfigHelper
(
Platform
.
Linux
,
configurationService
);
configHelper
.
panelContainer
=
fixture
;
assert
.
deepEqual
(
configHelper
.
getScrollback
(),
20
,
'
terminal.integrated.scrollback should be 20
'
);
});
});
\ No newline at end of file
src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts
浏览文件 @
70d9a5c1
...
...
@@ -78,7 +78,7 @@ suite('Workbench - TerminalInstance', () => {
suite
(
'
_getCwd
'
,
()
=>
{
let
instance
:
TestTerminalInstance
;
let
instantiationService
:
TestInstantiationService
;
let
configHelper
:
{
getCwd
:
()
=>
string
};
let
configHelper
:
{
config
:
{
cwd
:
string
}
};
setup
(()
=>
{
let
contextKeyService
=
new
MockKeybindingService
();
...
...
@@ -90,7 +90,9 @@ suite('Workbench - TerminalInstance', () => {
instantiationService
.
stub
(
IKeybindingService
,
keybindingService
);
instantiationService
.
stub
(
IContextKeyService
,
contextKeyService
);
configHelper
=
{
getCwd
:
()
=>
null
config
:
{
cwd
:
null
}
};
instance
=
instantiationService
.
createInstance
(
TestTerminalInstance
,
terminalFocusContextKey
,
configHelper
,
null
,
null
,
null
);
});
...
...
@@ -109,30 +111,30 @@ suite('Workbench - TerminalInstance', () => {
});
test
(
'
should use an absolute custom cwd as is
'
,
()
=>
{
configHelper
.
getCwd
=
()
=>
'
/foo
'
;
configHelper
.
config
.
cwd
=
'
/foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
null
),
'
/foo
'
);
});
test
(
'
should normalize a relative custom cwd against the workspace path
'
,
()
=>
{
configHelper
.
getCwd
=
()
=>
'
foo
'
;
configHelper
.
config
.
cwd
=
'
foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
{
resource
:
Uri
.
file
(
'
/bar
'
)
}),
'
/bar/foo
'
);
configHelper
.
getCwd
=
()
=>
'
./foo
'
;
configHelper
.
config
.
cwd
=
'
./foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
{
resource
:
Uri
.
file
(
'
/bar
'
)
}),
'
/bar/foo
'
);
configHelper
.
getCwd
=
()
=>
'
../foo
'
;
configHelper
.
config
.
cwd
=
'
../foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
{
resource
:
Uri
.
file
(
'
/bar
'
)
},
),
'
/foo
'
);
});
test
(
'
should fall back for relative a custom cwd that doesn
\'
t have a workspace
'
,
()
=>
{
configHelper
.
getCwd
=
()
=>
'
foo
'
;
configHelper
.
config
.
cwd
=
'
foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
null
),
os
.
homedir
());
configHelper
.
getCwd
=
()
=>
'
./foo
'
;
configHelper
.
config
.
cwd
=
'
./foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
null
),
os
.
homedir
());
configHelper
.
getCwd
=
()
=>
'
../foo
'
;
configHelper
.
config
.
cwd
=
'
../foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[]
},
null
),
os
.
homedir
());
});
test
(
'
should ignore custom cwd when told to ignore
'
,
()
=>
{
configHelper
.
getCwd
=
()
=>
'
/foo
'
;
configHelper
.
config
.
cwd
=
'
/foo
'
;
assertPathsMatch
(
instance
.
_getCwd
({
executable
:
null
,
args
:
[],
ignoreConfigurationCwd
:
true
},
{
resource
:
Uri
.
file
(
'
/bar
'
)
}),
'
/bar
'
);
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录