Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ff5ae224
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,发现更多精彩内容 >>
提交
ff5ae224
编写于
3月 04, 2019
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove more from electron-browser/terminalService
上级
437f7f67
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
85 addition
and
72 deletion
+85
-72
src/vs/workbench/contrib/terminal/browser/terminal.ts
src/vs/workbench/contrib/terminal/browser/terminal.ts
+4
-0
src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
...orkbench/contrib/terminal/browser/terminalConfigHelper.ts
+3
-2
src/vs/workbench/contrib/terminal/browser/terminalService.ts
src/vs/workbench/contrib/terminal/browser/terminalService.ts
+17
-2
src/vs/workbench/contrib/terminal/common/terminalService.ts
src/vs/workbench/contrib/terminal/common/terminalService.ts
+44
-1
src/vs/workbench/contrib/terminal/electron-browser/terminalService.ts
...ench/contrib/terminal/electron-browser/terminalService.ts
+17
-50
src/vs/workbench/contrib/terminal/node/terminal.ts
src/vs/workbench/contrib/terminal/node/terminal.ts
+0
-17
未找到文件。
src/vs/workbench/contrib/terminal/browser/terminal.ts
浏览文件 @
ff5ae224
...
...
@@ -18,3 +18,7 @@ export interface ITerminalInstanceService {
createTerminalProcessManager
(
id
:
number
,
configHelper
:
ITerminalConfigHelper
):
ITerminalProcessManager
;
createTerminalProcess
(
shellLaunchConfig
:
IShellLaunchConfig
,
cwd
:
string
,
cols
:
number
,
rows
:
number
,
env
:
IProcessEnvironment
,
windowsEnableConpty
:
boolean
):
ITerminalChildProcess
;
}
export
interface
IBrowserTerminalConfigHelper
extends
ITerminalConfigHelper
{
panelContainer
:
HTMLElement
;
}
src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
浏览文件 @
ff5ae224
...
...
@@ -10,10 +10,11 @@ import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/ed
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkspaceConfigurationService
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITerminalConfiguration
,
ITerminal
ConfigHelper
,
ITerminal
Font
,
IShellLaunchConfig
,
IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY
,
TERMINAL_CONFIG_SECTION
,
DEFAULT_LETTER_SPACING
,
DEFAULT_LINE_HEIGHT
,
MINIMUM_LETTER_SPACING
,
LinuxDistro
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITerminalConfiguration
,
ITerminalFont
,
IShellLaunchConfig
,
IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY
,
TERMINAL_CONFIG_SECTION
,
DEFAULT_LETTER_SPACING
,
DEFAULT_LINE_HEIGHT
,
MINIMUM_LETTER_SPACING
,
LinuxDistro
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
Terminal
as
XTermTerminal
}
from
'
vscode-xterm
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IBrowserTerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
const
MINIMUM_FONT_SIZE
=
6
;
const
MAXIMUM_FONT_SIZE
=
25
;
...
...
@@ -22,7 +23,7 @@ const MAXIMUM_FONT_SIZE = 25;
* Encapsulates terminal configuration logic, the primary purpose of this file is so that platform
* specific test cases can be written.
*/
export
class
TerminalConfigHelper
implements
ITerminalConfigHelper
{
export
class
TerminalConfigHelper
implements
I
Browser
TerminalConfigHelper
{
public
panelContainer
:
HTMLElement
;
private
_charMeasureElement
:
HTMLElement
;
...
...
src/vs/workbench/contrib/terminal/browser/terminalService.ts
浏览文件 @
ff5ae224
...
...
@@ -5,9 +5,9 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
ITerminalService
,
TERMINAL_PANEL_ID
,
ITerminalInstance
,
IShellLaunchConfig
,
NEVER_SUGGEST_SELECT_WINDOWS_SHELL_STORAGE_KEY
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITerminalService
,
TERMINAL_PANEL_ID
,
ITerminalInstance
,
IShellLaunchConfig
,
NEVER_SUGGEST_SELECT_WINDOWS_SHELL_STORAGE_KEY
,
ITerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
TerminalService
as
CommonTerminalService
}
from
'
vs/workbench/contrib/terminal/common/terminalService
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
...
...
@@ -20,8 +20,11 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
TerminalInstance
}
from
'
vs/workbench/contrib/terminal/browser/terminalInstance
'
;
import
{
IBrowserTerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
export
abstract
class
TerminalService
extends
CommonTerminalService
implements
ITerminalService
{
protected
_configHelper
:
IBrowserTerminalConfigHelper
;
constructor
(
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
...
...
@@ -41,6 +44,12 @@ export abstract class TerminalService extends CommonTerminalService implements I
protected
abstract
_getDefaultShell
(
p
:
platform
.
Platform
):
string
;
public
createInstance
(
terminalFocusContextKey
:
IContextKey
<
boolean
>
,
configHelper
:
ITerminalConfigHelper
,
container
:
HTMLElement
|
undefined
,
shellLaunchConfig
:
IShellLaunchConfig
,
doCreateProcess
:
boolean
):
ITerminalInstance
{
const
instance
=
this
.
_instantiationService
.
createInstance
(
TerminalInstance
,
terminalFocusContextKey
,
configHelper
,
container
,
shellLaunchConfig
);
this
.
_onInstanceCreated
.
fire
(
instance
);
return
instance
;
}
public
createTerminal
(
shell
:
IShellLaunchConfig
=
{},
wasNewTerminalAction
?:
boolean
):
ITerminalInstance
{
const
terminalTab
=
this
.
_instantiationService
.
createInstance
(
TerminalTab
,
this
.
_terminalFocusContextKey
,
...
...
@@ -157,4 +166,10 @@ export abstract class TerminalService extends CommonTerminalService implements I
panel
.
getFindWidget
().
find
(
true
);
}
}
public
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
{
this
.
_configHelper
.
panelContainer
=
panelContainer
;
this
.
_terminalContainer
=
terminalContainer
;
this
.
_terminalTabs
.
forEach
(
tab
=>
tab
.
attachToElement
(
this
.
_terminalContainer
));
}
}
\ No newline at end of file
src/vs/workbench/contrib/terminal/common/terminalService.ts
浏览文件 @
ff5ae224
...
...
@@ -17,6 +17,9 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
escapeNonWindowsPath
}
from
'
vs/workbench/contrib/terminal/common/terminalEnvironment
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
basename
}
from
'
vs/base/common/path
'
;
export
abstract
class
TerminalService
implements
ITerminalService
{
public
_serviceBrand
:
any
;
...
...
@@ -97,11 +100,13 @@ export abstract class TerminalService implements ITerminalService {
this
.
onInstancesChanged
(()
=>
updateTerminalContextKeys
());
}
protected
abstract
_getWslPath
(
path
:
string
):
Promise
<
string
>
;
protected
abstract
_getWindowsBuildNumber
():
number
;
public
abstract
createTerminal
(
shell
?:
IShellLaunchConfig
,
wasNewTerminalAction
?:
boolean
):
ITerminalInstance
;
public
abstract
createInstance
(
terminalFocusContextKey
:
IContextKey
<
boolean
>
,
configHelper
:
ITerminalConfigHelper
,
container
:
HTMLElement
,
shellLaunchConfig
:
IShellLaunchConfig
,
doCreateProcess
:
boolean
):
ITerminalInstance
;
public
abstract
selectDefaultWindowsShell
():
Promise
<
string
|
undefined
>
;
public
abstract
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
;
public
abstract
preparePathForTerminalAsync
(
path
:
string
,
executable
:
string
,
title
:
string
):
Promise
<
string
>
;
public
createTerminalRenderer
(
name
:
string
):
ITerminalInstance
{
return
this
.
createTerminal
({
name
,
isRendererOnly
:
true
});
...
...
@@ -425,4 +430,42 @@ export abstract class TerminalService implements ITerminalService {
return
[
label
,
current
]
as
[
string
,
string
];
});
}
public
preparePathForTerminalAsync
(
originalPath
:
string
,
executable
:
string
,
title
:
string
):
Promise
<
string
>
{
return
new
Promise
<
string
>
(
c
=>
{
const
exe
=
executable
;
if
(
!
exe
)
{
c
(
originalPath
);
return
;
}
const
hasSpace
=
originalPath
.
indexOf
(
'
'
)
!==
-
1
;
const
pathBasename
=
basename
(
exe
,
'
.exe
'
);
const
isPowerShell
=
pathBasename
===
'
pwsh
'
||
title
===
'
pwsh
'
||
pathBasename
===
'
powershell
'
||
title
===
'
powershell
'
;
if
(
isPowerShell
&&
(
hasSpace
||
originalPath
.
indexOf
(
'
\'
'
)
!==
-
1
))
{
c
(
`& '
${
originalPath
.
replace
(
/'/g
,
'
\'\'
'
)}
'`
);
return
;
}
if
(
isWindows
)
{
// 17063 is the build number where wsl path was introduced.
// Update Windows uriPath to be executed in WSL.
if
(((
exe
.
indexOf
(
'
wsl
'
)
!==
-
1
)
||
((
exe
.
indexOf
(
'
bash.exe
'
)
!==
-
1
)
&&
(
exe
.
indexOf
(
'
git
'
)
===
-
1
)))
&&
(
this
.
_getWindowsBuildNumber
()
>=
17063
))
{
c
(
this
.
_getWslPath
(
originalPath
));
return
;
}
else
if
(
hasSpace
)
{
c
(
'
"
'
+
originalPath
+
'
"
'
);
}
else
{
c
(
originalPath
);
}
return
;
}
c
(
escapeNonWindowsPath
(
originalPath
));
});
}
}
src/vs/workbench/contrib/terminal/electron-browser/terminalService.ts
浏览文件 @
ff5ae224
...
...
@@ -6,31 +6,29 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
IConfigurationService
,
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITerminal
Instance
,
ITerminalService
,
IShellLaunchConfig
,
ITerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITerminal
Service
,
ITerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
TerminalService
as
BrowserTerminalService
}
from
'
vs/workbench/contrib/terminal/browser/terminalService
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/browser/terminalConfigHelper
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
getDefaultShell
,
linuxDistro
,
getWindowsBuildNumber
,
getWslPath
}
from
'
vs/workbench/contrib/terminal/node/terminal
'
;
import
{
getDefaultShell
,
linuxDistro
,
getWindowsBuildNumber
}
from
'
vs/workbench/contrib/terminal/node/terminal
'
;
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
ipcRenderer
as
ipc
}
from
'
electron
'
;
import
{
IOpenFileRequest
,
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
TerminalInstance
}
from
'
vs/workbench/contrib/terminal/browser/terminalInstance
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
IPickOptions
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
escapeNonWindowsPath
}
from
'
vs/workbench/contrib/terminal/common/terminalEnvironment
'
;
import
{
basename
}
from
'
vs/base/common/path
'
;
import
{
execFile
}
from
'
child_process
'
;
export
class
TerminalService
extends
BrowserTerminalService
implements
ITerminalService
{
private
_configHelper
:
TerminalConfigHelper
;
public
get
configHelper
():
ITerminalConfigHelper
{
return
this
.
_configHelper
;
}
constructor
(
...
...
@@ -75,12 +73,6 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
});
}
public
createInstance
(
terminalFocusContextKey
:
IContextKey
<
boolean
>
,
configHelper
:
ITerminalConfigHelper
,
container
:
HTMLElement
|
undefined
,
shellLaunchConfig
:
IShellLaunchConfig
,
doCreateProcess
:
boolean
):
ITerminalInstance
{
const
instance
=
this
.
_instantiationService
.
createInstance
(
TerminalInstance
,
terminalFocusContextKey
,
configHelper
,
container
,
shellLaunchConfig
);
this
.
_onInstanceCreated
.
fire
(
instance
);
return
instance
;
}
protected
_getDefaultShell
(
p
:
platform
.
Platform
):
string
{
return
getDefaultShell
(
p
);
}
...
...
@@ -140,47 +132,22 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
});
}
public
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
{
this
.
_configHelper
.
panelContainer
=
panelContainer
;
this
.
_terminalContainer
=
terminalContainer
;
this
.
_terminalTabs
.
forEach
(
tab
=>
tab
.
attachToElement
(
this
.
_terminalContainer
));
protected
_getWindowsBuildNumber
():
number
{
return
getWindowsBuildNumber
();
}
public
preparePathForTerminalAsync
(
originalPath
:
string
,
executable
:
string
,
title
:
string
):
Promise
<
string
>
{
/**
* Converts a path to a path on WSL using the wslpath utility.
* @param path The original path.
*/
protected
_getWslPath
(
path
:
string
):
Promise
<
string
>
{
if
(
getWindowsBuildNumber
()
<
17063
)
{
throw
new
Error
(
'
wslpath does not exist on Windows build < 17063
'
);
}
return
new
Promise
<
string
>
(
c
=>
{
const
exe
=
executable
;
if
(
!
exe
)
{
c
(
originalPath
);
return
;
}
const
hasSpace
=
originalPath
.
indexOf
(
'
'
)
!==
-
1
;
const
pathBasename
=
basename
(
exe
,
'
.exe
'
);
const
isPowerShell
=
pathBasename
===
'
pwsh
'
||
title
===
'
pwsh
'
||
pathBasename
===
'
powershell
'
||
title
===
'
powershell
'
;
if
(
isPowerShell
&&
(
hasSpace
||
originalPath
.
indexOf
(
'
\'
'
)
!==
-
1
))
{
c
(
`& '
${
originalPath
.
replace
(
/'/g
,
'
\'\'
'
)}
'`
);
return
;
}
if
(
platform
.
isWindows
)
{
// 17063 is the build number where wsl path was introduced.
// Update Windows uriPath to be executed in WSL.
if
(((
exe
.
indexOf
(
'
wsl
'
)
!==
-
1
)
||
((
exe
.
indexOf
(
'
bash.exe
'
)
!==
-
1
)
&&
(
exe
.
indexOf
(
'
git
'
)
===
-
1
)))
&&
(
getWindowsBuildNumber
()
>=
17063
))
{
c
(
getWslPath
(
originalPath
));
return
;
}
else
if
(
hasSpace
)
{
c
(
'
"
'
+
originalPath
+
'
"
'
);
}
else
{
c
(
originalPath
);
}
return
;
}
c
(
escapeNonWindowsPath
(
originalPath
));
execFile
(
'
bash.exe
'
,
[
'
-c
'
,
'
echo $(wslpath
'
+
escapeNonWindowsPath
(
path
)
+
'
)
'
],
{},
(
error
,
stdout
,
stderr
)
=>
{
c
(
escapeNonWindowsPath
(
stdout
.
trim
()));
});
});
}
}
src/vs/workbench/contrib/terminal/node/terminal.ts
浏览文件 @
ff5ae224
...
...
@@ -8,8 +8,6 @@ import * as platform from 'vs/base/common/platform';
import
*
as
processes
from
'
vs/base/node/processes
'
;
import
{
readFile
,
fileExists
}
from
'
vs/base/node/pfs
'
;
import
{
LinuxDistro
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
execFile
}
from
'
child_process
'
;
import
{
escapeNonWindowsPath
}
from
'
vs/workbench/contrib/terminal/common/terminalEnvironment
'
;
export
function
getDefaultShell
(
p
:
platform
.
Platform
):
string
{
if
(
p
===
platform
.
Platform
.
Windows
)
{
...
...
@@ -84,18 +82,3 @@ export function getWindowsBuildNumber(): number {
}
return
buildNumber
;
}
/**
* Converts a path to a path on WSL using the wslpath utility.
* @param path The original path.
*/
export
function
getWslPath
(
path
:
string
):
Promise
<
string
>
{
if
(
getWindowsBuildNumber
()
<
17063
)
{
throw
new
Error
(
'
wslpath does not exist on Windows build < 17063
'
);
}
return
new
Promise
<
string
>
(
c
=>
{
execFile
(
'
bash.exe
'
,
[
'
-c
'
,
'
echo $(wslpath
'
+
escapeNonWindowsPath
(
path
)
+
'
)
'
],
{},
(
error
,
stdout
,
stderr
)
=>
{
c
(
escapeNonWindowsPath
(
stdout
.
trim
()));
});
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录