Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
48633183
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,发现更多精彩内容 >>
未验证
提交
48633183
编写于
10月 02, 2018
作者:
D
Daniel Imms
提交者:
GitHub
10月 02, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #59754 from Microsoft/tyriar/53526
Remove TPromise usage in terminal and execution parts
上级
6ad61f01
925269a4
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
155 addition
and
168 deletion
+155
-168
src/vs/workbench/parts/execution/common/execution.ts
src/vs/workbench/parts/execution/common/execution.ts
+1
-2
src/vs/workbench/parts/execution/electron-browser/terminal.ts
...vs/workbench/parts/execution/electron-browser/terminal.ts
+4
-5
src/vs/workbench/parts/execution/electron-browser/terminalService.ts
...bench/parts/execution/electron-browser/terminalService.ts
+15
-16
src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
+2
-3
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+5
-6
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+6
-7
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
...kbench/parts/terminal/electron-browser/terminalActions.ts
+95
-96
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+1
-2
src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts
...ch/parts/terminal/electron-browser/terminalLinkHandler.ts
+4
-5
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
...orkbench/parts/terminal/electron-browser/terminalPanel.ts
+5
-6
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
...parts/terminal/electron-browser/terminalProcessManager.ts
+2
-3
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
...kbench/parts/terminal/electron-browser/terminalService.ts
+9
-10
src/vs/workbench/parts/terminal/node/windowsShellHelper.ts
src/vs/workbench/parts/terminal/node/windowsShellHelper.ts
+6
-7
未找到文件。
src/vs/workbench/parts/execution/common/execution.ts
浏览文件 @
48633183
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IProcessEnvironment
}
from
'
vs/base/common/platform
'
;
export
const
ITerminalService
=
createDecorator
<
ITerminalService
>
(
'
nativeTerminalService
'
);
...
...
@@ -12,5 +11,5 @@ export const ITerminalService = createDecorator<ITerminalService>('nativeTermina
export
interface
ITerminalService
{
_serviceBrand
:
any
;
openTerminal
(
path
:
string
):
void
;
runInTerminal
(
title
:
string
,
cwd
:
string
,
args
:
string
[],
env
:
IProcessEnvironment
):
T
Promise
<
void
>
;
runInTerminal
(
title
:
string
,
cwd
:
string
,
args
:
string
[],
env
:
IProcessEnvironment
):
Promise
<
void
>
;
}
\ No newline at end of file
src/vs/workbench/parts/execution/electron-browser/terminal.ts
浏览文件 @
48633183
...
...
@@ -5,14 +5,13 @@
import
*
as
env
from
'
vs/base/common/platform
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
let
_DEFAULT_TERMINAL_LINUX_READY
:
T
Promise
<
string
>
=
null
;
export
function
getDefaultTerminalLinuxReady
():
T
Promise
<
string
>
{
let
_DEFAULT_TERMINAL_LINUX_READY
:
Promise
<
string
>
=
null
;
export
function
getDefaultTerminalLinuxReady
():
Promise
<
string
>
{
if
(
!
_DEFAULT_TERMINAL_LINUX_READY
)
{
_DEFAULT_TERMINAL_LINUX_READY
=
new
T
Promise
<
string
>
(
c
=>
{
_DEFAULT_TERMINAL_LINUX_READY
=
new
Promise
<
string
>
(
c
=>
{
if
(
env
.
isLinux
)
{
TPromise
.
join
([
pfs
.
exists
(
'
/etc/debian_version
'
),
process
.
lazyEnv
]).
then
(([
isDebian
])
=>
{
Promise
.
all
([
pfs
.
exists
(
'
/etc/debian_version
'
),
process
.
lazyEnv
]).
then
(([
isDebian
])
=>
{
if
(
isDebian
)
{
c
(
'
x-terminal-emulator
'
);
}
else
if
(
process
.
env
.
DESKTOP_SESSION
===
'
gnome
'
||
process
.
env
.
DESKTOP_SESSION
===
'
gnome-classic
'
)
{
...
...
src/vs/workbench/parts/execution/electron-browser/terminalService.ts
浏览文件 @
48633183
...
...
@@ -8,7 +8,6 @@ import * as path from 'path';
import
*
as
processes
from
'
vs/base/node/processes
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ITerminalService
}
from
'
vs/workbench/parts/execution/common/execution
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITerminalConfiguration
,
getDefaultTerminalWindows
,
getDefaultTerminalLinuxReady
,
DEFAULT_TERMINAL_OSX
}
from
'
vs/workbench/parts/execution/electron-browser/terminal
'
;
...
...
@@ -38,13 +37,13 @@ export class WinTerminalService implements ITerminalService {
this
.
spawnTerminal
(
cp
,
configuration
,
processes
.
getWindowsShell
(),
cwd
);
}
public
runInTerminal
(
title
:
string
,
dir
:
string
,
args
:
string
[],
envVars
:
IProcessEnvironment
):
T
Promise
<
void
>
{
public
runInTerminal
(
title
:
string
,
dir
:
string
,
args
:
string
[],
envVars
:
IProcessEnvironment
):
Promise
<
void
>
{
const
configuration
=
this
.
_configurationService
.
getValue
<
ITerminalConfiguration
>
();
const
terminalConfig
=
configuration
.
terminal
.
external
;
const
exec
=
terminalConfig
.
windowsExec
||
getDefaultTerminalWindows
();
return
new
T
Promise
<
void
>
((
c
,
e
)
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
const
title
=
`"
${
dir
}
-
${
TERMINAL_TITLE
}
"`
;
const
command
=
`""
${
args
.
join
(
'
" "
'
)}
" & pause"`
;
// use '|' to only pause on non-zero exit code
...
...
@@ -72,7 +71,7 @@ export class WinTerminalService implements ITerminalService {
});
}
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
command
:
string
,
cwd
?:
string
):
T
Promise
<
void
>
{
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
command
:
string
,
cwd
?:
string
):
Promise
<
void
>
{
const
terminalConfig
=
configuration
.
terminal
.
external
;
const
exec
=
terminalConfig
.
windowsExec
||
getDefaultTerminalWindows
();
const
spawnType
=
this
.
getSpawnType
(
exec
);
...
...
@@ -86,14 +85,14 @@ export class WinTerminalService implements ITerminalService {
// unless otherwise specified
if
(
spawnType
===
WinSpawnType
.
CMDER
)
{
spawner
.
spawn
(
exec
,
[
cwd
]);
return
TPromise
.
as
(
void
0
);
return
Promise
.
resolve
(
void
0
);
}
// The '""' argument is the window title. Without this, exec doesn't work when the path
// contains spaces
const
cmdArgs
=
[
'
/c
'
,
'
start
'
,
'
/wait
'
,
'
""
'
,
exec
];
return
new
T
Promise
<
void
>
((
c
,
e
)
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
const
env
=
cwd
?
{
cwd
:
cwd
}
:
void
0
;
const
child
=
spawner
.
spawn
(
command
,
cmdArgs
,
env
);
child
.
on
(
'
error
'
,
e
);
...
...
@@ -125,13 +124,13 @@ export class MacTerminalService implements ITerminalService {
this
.
spawnTerminal
(
cp
,
configuration
,
cwd
);
}
public
runInTerminal
(
title
:
string
,
dir
:
string
,
args
:
string
[],
envVars
:
IProcessEnvironment
):
T
Promise
<
void
>
{
public
runInTerminal
(
title
:
string
,
dir
:
string
,
args
:
string
[],
envVars
:
IProcessEnvironment
):
Promise
<
void
>
{
const
configuration
=
this
.
_configurationService
.
getValue
<
ITerminalConfiguration
>
();
const
terminalConfig
=
configuration
.
terminal
.
external
;
const
terminalApp
=
terminalConfig
.
osxExec
||
DEFAULT_TERMINAL_OSX
;
return
new
T
Promise
<
void
>
((
c
,
e
)
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
if
(
terminalApp
===
DEFAULT_TERMINAL_OSX
||
terminalApp
===
'
iTerm.app
'
)
{
...
...
@@ -189,11 +188,11 @@ export class MacTerminalService implements ITerminalService {
});
}
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
cwd
?:
string
):
T
Promise
<
void
>
{
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
cwd
?:
string
):
Promise
<
void
>
{
const
terminalConfig
=
configuration
.
terminal
.
external
;
const
terminalApp
=
terminalConfig
.
osxExec
||
DEFAULT_TERMINAL_OSX
;
return
new
T
Promise
<
void
>
((
c
,
e
)
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
const
child
=
spawner
.
spawn
(
'
/usr/bin/open
'
,
[
'
-a
'
,
terminalApp
,
cwd
]);
child
.
on
(
'
error
'
,
e
);
child
.
on
(
'
exit
'
,
()
=>
c
(
null
));
...
...
@@ -217,13 +216,13 @@ export class LinuxTerminalService implements ITerminalService {
this
.
spawnTerminal
(
cp
,
configuration
,
cwd
);
}
public
runInTerminal
(
title
:
string
,
dir
:
string
,
args
:
string
[],
envVars
:
IProcessEnvironment
):
T
Promise
<
void
>
{
public
runInTerminal
(
title
:
string
,
dir
:
string
,
args
:
string
[],
envVars
:
IProcessEnvironment
):
Promise
<
void
>
{
const
configuration
=
this
.
_configurationService
.
getValue
<
ITerminalConfiguration
>
();
const
terminalConfig
=
configuration
.
terminal
.
external
;
const
execPromise
=
terminalConfig
.
linuxExec
?
TPromise
.
as
(
terminalConfig
.
linuxExec
)
:
getDefaultTerminalLinuxReady
();
const
execPromise
=
terminalConfig
.
linuxExec
?
Promise
.
resolve
(
terminalConfig
.
linuxExec
)
:
getDefaultTerminalLinuxReady
();
return
new
T
Promise
<
void
>
((
c
,
e
)
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
let
termArgs
:
string
[]
=
[];
//termArgs.push('--title');
...
...
@@ -273,12 +272,12 @@ export class LinuxTerminalService implements ITerminalService {
});
}
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
cwd
?:
string
):
T
Promise
<
void
>
{
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
cwd
?:
string
):
Promise
<
void
>
{
const
terminalConfig
=
configuration
.
terminal
.
external
;
const
execPromise
=
terminalConfig
.
linuxExec
?
TPromise
.
as
(
terminalConfig
.
linuxExec
)
:
getDefaultTerminalLinuxReady
();
const
execPromise
=
terminalConfig
.
linuxExec
?
Promise
.
resolve
(
terminalConfig
.
linuxExec
)
:
getDefaultTerminalLinuxReady
();
const
env
=
cwd
?
{
cwd
:
cwd
}
:
void
0
;
return
new
T
Promise
<
void
>
((
c
,
e
)
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
execPromise
.
then
(
exec
=>
{
const
child
=
spawner
.
spawn
(
exec
,
[],
env
);
child
.
on
(
'
error
'
,
e
);
...
...
src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
浏览文件 @
48633183
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Mode
,
IEntryRunContext
,
IAutoFocus
,
IQuickNavigateConfiguration
,
IModel
}
from
'
vs/base/parts/quickopen/common/quickOpen
'
;
import
{
QuickOpenModel
,
QuickOpenEntry
}
from
'
vs/base/parts/quickopen/browser/quickOpenModel
'
;
import
{
QuickOpenHandler
}
from
'
vs/workbench/browser/quickopen
'
;
...
...
@@ -84,7 +83,7 @@ export class TerminalPickerHandler extends QuickOpenHandler {
super
();
}
public
getResults
(
searchValue
:
string
,
token
:
CancellationToken
):
T
Promise
<
QuickOpenModel
>
{
public
getResults
(
searchValue
:
string
,
token
:
CancellationToken
):
Promise
<
QuickOpenModel
>
{
searchValue
=
searchValue
.
trim
();
const
normalizedSearchValueLowercase
=
stripWildcards
(
searchValue
).
toLowerCase
();
...
...
@@ -106,7 +105,7 @@ export class TerminalPickerHandler extends QuickOpenHandler {
return
true
;
});
return
TPromise
.
as
(
new
QuickOpenModel
(
entries
,
new
ContributableActionProvider
()));
return
Promise
.
resolve
(
new
QuickOpenModel
(
entries
,
new
ContributableActionProvider
()));
}
private
getTerminals
():
TerminalEntry
[]
{
...
...
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
48633183
...
...
@@ -7,7 +7,6 @@ import { Event } from 'vs/base/common/event';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
RawContextKey
,
ContextKeyExpr
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
FindReplaceState
}
from
'
vs/editor/contrib/find/findState
'
;
...
...
@@ -225,16 +224,16 @@ export interface ITerminalService {
setActiveTabToPrevious
():
void
;
setActiveTabByIndex
(
tabIndex
:
number
):
void
;
showPanel
(
focus
?:
boolean
):
T
Promise
<
void
>
;
showPanel
(
focus
?:
boolean
):
Promise
<
void
>
;
hidePanel
():
void
;
focusFindWidget
():
T
Promise
<
void
>
;
focusFindWidget
():
Promise
<
void
>
;
hideFindWidget
():
void
;
getFindState
():
FindReplaceState
;
findNext
():
void
;
findPrevious
():
void
;
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
;
selectDefaultWindowsShell
():
T
Promise
<
string
>
;
selectDefaultWindowsShell
():
Promise
<
string
>
;
setWorkspaceShellAllowed
(
isAllowed
:
boolean
):
void
;
requestExtHostProcess
(
proxy
:
ITerminalProcessExtHostProxy
,
shellLaunchConfig
:
IShellLaunchConfig
,
cols
:
number
,
rows
:
number
):
void
;
...
...
@@ -360,7 +359,7 @@ export interface ITerminalInstance {
*/
onExit
:
Event
<
number
>
;
processReady
:
T
Promise
<
void
>
;
processReady
:
Promise
<
void
>
;
/**
* The title of the terminal. This is either title or the process currently running or an
...
...
@@ -598,7 +597,7 @@ export interface ITerminalCommandTracker {
export
interface
ITerminalProcessManager
extends
IDisposable
{
readonly
processState
:
ProcessState
;
readonly
ptyProcessReady
:
T
Promise
<
void
>
;
readonly
ptyProcessReady
:
Promise
<
void
>
;
readonly
shellProcessId
:
number
;
readonly
initialCwd
:
string
;
...
...
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
48633183
...
...
@@ -9,7 +9,6 @@ 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
{
ITerminalService
,
ITerminalInstance
,
IShellLaunchConfig
,
ITerminalConfigHelper
,
KEYBINDING_CONTEXT_TERMINAL_FOCUS
,
KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE
,
TERMINAL_PANEL_ID
,
ITerminalTab
,
ITerminalProcessExtHostProxy
,
ITerminalProcessExtHostRequest
,
KEYBINDING_CONTEXT_TERMINAL_IS_OPEN
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
FindReplaceState
}
from
'
vs/editor/contrib/find/findState
'
;
...
...
@@ -82,17 +81,17 @@ export abstract class TerminalService implements ITerminalService {
this
.
onInstancesChanged
(()
=>
updateTerminalContextKeys
());
}
protected
abstract
_showTerminalCloseConfirmation
():
TPromis
e
<
boolean
>
;
protected
abstract
_showTerminalCloseConfirmation
():
PromiseLik
e
<
boolean
>
;
protected
abstract
_showNotEnoughSpaceToast
():
void
;
public
abstract
createTerminal
(
shell
?:
IShellLaunchConfig
,
wasNewTerminalAction
?:
boolean
):
ITerminalInstance
;
public
abstract
createTerminalRenderer
(
name
:
string
):
ITerminalInstance
;
public
abstract
createInstance
(
terminalFocusContextKey
:
IContextKey
<
boolean
>
,
configHelper
:
ITerminalConfigHelper
,
container
:
HTMLElement
,
shellLaunchConfig
:
IShellLaunchConfig
,
doCreateProcess
:
boolean
):
ITerminalInstance
;
public
abstract
getActiveOrCreateInstance
(
wasNewTerminalAction
?:
boolean
):
ITerminalInstance
;
public
abstract
selectDefaultWindowsShell
():
T
Promise
<
string
>
;
public
abstract
selectDefaultWindowsShell
():
Promise
<
string
>
;
public
abstract
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
;
public
abstract
requestExtHostProcess
(
proxy
:
ITerminalProcessExtHostProxy
,
shellLaunchConfig
:
IShellLaunchConfig
,
cols
:
number
,
rows
:
number
):
void
;
private
_onWillShutdown
():
boolean
|
TPromis
e
<
boolean
>
{
private
_onWillShutdown
():
boolean
|
PromiseLik
e
<
boolean
>
{
if
(
this
.
terminalInstances
.
length
===
0
)
{
// No terminal instances, don't veto
return
false
;
...
...
@@ -292,8 +291,8 @@ export abstract class TerminalService implements ITerminalService {
return
null
;
}
public
showPanel
(
focus
?:
boolean
):
T
Promise
<
void
>
{
return
new
T
Promise
<
void
>
((
complete
)
=>
{
public
showPanel
(
focus
?:
boolean
):
Promise
<
void
>
{
return
new
Promise
<
void
>
((
complete
)
=>
{
const
panel
=
this
.
_panelService
.
getActivePanel
();
if
(
!
panel
||
panel
.
getId
()
!==
TERMINAL_PANEL_ID
)
{
return
this
.
_panelService
.
openPanel
(
TERMINAL_PANEL_ID
,
focus
).
then
(()
=>
{
...
...
@@ -339,7 +338,7 @@ export abstract class TerminalService implements ITerminalService {
}
}
public
abstract
focusFindWidget
():
T
Promise
<
void
>
;
public
abstract
focusFindWidget
():
Promise
<
void
>
;
public
abstract
hideFindWidget
():
void
;
public
abstract
findNext
():
void
;
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
浏览文件 @
48633183
此差异已折叠。
点击以展开。
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
48633183
...
...
@@ -24,7 +24,6 @@ import { TerminalLinkHandler } from 'vs/workbench/parts/terminal/electron-browse
import
{
TerminalWidgetManager
}
from
'
vs/workbench/parts/terminal/browser/terminalWidgetManager
'
;
import
{
registerThemingParticipant
,
ITheme
,
ICssStyleCollector
,
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
scrollbarSliderBackground
,
scrollbarSliderHoverBackground
,
scrollbarSliderActiveBackground
,
activeContrastBorder
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
ansiColorIdentifiers
,
TERMINAL_BACKGROUND_COLOR
,
TERMINAL_FOREGROUND_COLOR
,
TERMINAL_CURSOR_FOREGROUND_COLOR
,
TERMINAL_CURSOR_BACKGROUND_COLOR
,
TERMINAL_SELECTION_BACKGROUND_COLOR
}
from
'
vs/workbench/parts/terminal/common/terminalColorRegistry
'
;
import
{
PANEL_BACKGROUND
}
from
'
vs/workbench/common/theme
'
;
...
...
@@ -86,7 +85,7 @@ export class TerminalInstance implements ITerminalInstance {
public
get
processId
():
number
|
undefined
{
return
this
.
_processManager
?
this
.
_processManager
.
shellProcessId
:
undefined
;
}
// TODO: How does this work with detached processes?
// TODO: Should this be an event as it can fire twice?
public
get
processReady
():
TPromise
<
void
>
{
return
this
.
_processManager
?
this
.
_processManager
.
ptyProcessReady
:
TPromise
.
as
(
void
0
);
}
public
get
processReady
():
Promise
<
void
>
{
return
this
.
_processManager
?
this
.
_processManager
.
ptyProcessReady
:
Promise
.
resolve
(
void
0
);
}
public
get
title
():
string
{
return
this
.
_title
;
}
public
get
hadFocusOnExit
():
boolean
{
return
this
.
_hadFocusOnExit
;
}
public
get
isTitleSetByProcess
():
boolean
{
return
!!
this
.
_messageTitleDisposable
;
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts
浏览文件 @
48633183
...
...
@@ -11,7 +11,6 @@ import { URI as Uri } from 'vs/base/common/uri';
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
TerminalWidgetManager
}
from
'
vs/workbench/parts/terminal/browser/terminalWidgetManager
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITerminalService
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
ITextEditorSelection
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -169,7 +168,7 @@ export class TerminalLinkHandler {
return
this
.
_localLinkPattern
;
}
private
_handleLocalLink
(
link
:
string
):
TPromis
e
<
any
>
{
private
_handleLocalLink
(
link
:
string
):
PromiseLik
e
<
any
>
{
return
this
.
_resolvePath
(
link
).
then
(
resolvedLink
=>
{
const
normalizedPath
=
path
.
normalize
(
path
.
resolve
(
resolvedLink
));
const
normalizedUrl
=
this
.
extractLinkUrl
(
normalizedPath
);
...
...
@@ -246,15 +245,15 @@ export class TerminalLinkHandler {
return
link
;
}
private
_resolvePath
(
link
:
string
):
TPromis
e
<
string
>
{
private
_resolvePath
(
link
:
string
):
PromiseLik
e
<
string
>
{
link
=
this
.
_preprocessPath
(
link
);
if
(
!
link
)
{
return
TPromise
.
as
(
void
0
);
return
Promise
.
resolve
(
void
0
);
}
const
linkUrl
=
this
.
extractLinkUrl
(
link
);
if
(
!
linkUrl
)
{
return
TPromise
.
as
(
void
0
);
return
Promise
.
resolve
(
void
0
);
}
// Open an editor if the path exists
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
浏览文件 @
48633183
...
...
@@ -20,7 +20,6 @@ import { editorHoverBackground, editorHoverBorder, editorForeground } from 'vs/p
import
{
KillTerminalAction
,
SwitchTerminalAction
,
SwitchTerminalActionItem
,
CopyTerminalSelectionAction
,
TerminalPasteAction
,
ClearTerminalAction
,
SelectAllTerminalAction
,
CreateNewTerminalAction
,
SplitTerminalAction
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalActions
'
;
import
{
Panel
}
from
'
vs/workbench/browser/panel
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TERMINAL_BACKGROUND_COLOR
,
TERMINAL_BORDER_COLOR
}
from
'
vs/workbench/parts/terminal/common/terminalColorRegistry
'
;
import
{
DataTransfers
}
from
'
vs/base/browser/dnd
'
;
...
...
@@ -52,7 +51,7 @@ export class TerminalPanel extends Panel {
super
(
TERMINAL_PANEL_ID
,
telemetryService
,
_themeService
);
}
public
create
(
parent
:
HTMLElement
):
T
Promise
<
any
>
{
public
create
(
parent
:
HTMLElement
):
Promise
<
any
>
{
super
.
create
(
parent
);
this
.
_parentDomElement
=
parent
;
dom
.
addClass
(
this
.
_parentDomElement
,
'
integrated-terminal
'
);
...
...
@@ -97,7 +96,7 @@ export class TerminalPanel extends Panel {
// Force another layout (first is setContainers) since config has changed
this
.
layout
(
new
dom
.
Dimension
(
this
.
_terminalContainer
.
offsetWidth
,
this
.
_terminalContainer
.
offsetHeight
));
return
TPromise
.
as
(
void
0
);
return
Promise
.
resolve
(
void
0
);
}
public
layout
(
dimension
?:
dom
.
Dimension
):
void
{
...
...
@@ -107,7 +106,7 @@ export class TerminalPanel extends Panel {
this
.
_terminalService
.
terminalTabs
.
forEach
(
t
=>
t
.
layout
(
dimension
.
width
,
dimension
.
height
));
}
public
setVisible
(
visible
:
boolean
):
TPromis
e
<
void
>
{
public
setVisible
(
visible
:
boolean
):
PromiseLik
e
<
void
>
{
if
(
visible
)
{
if
(
this
.
_terminalService
.
terminalInstances
.
length
>
0
)
{
this
.
_updateFont
();
...
...
@@ -122,7 +121,7 @@ export class TerminalPanel extends Panel {
this
.
_updateFont
();
this
.
_updateTheme
();
}
return
TPromise
.
as
(
void
0
);
return
Promise
.
resolve
(
void
0
);
});
}
}
...
...
@@ -259,7 +258,7 @@ export class TerminalPanel extends Panel {
const
anchor
:
{
x
:
number
,
y
:
number
}
=
{
x
:
standardEvent
.
posx
,
y
:
standardEvent
.
posy
};
this
.
_contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
anchor
,
getActions
:
()
=>
TPromise
.
as
(
this
.
_getContextMenuActions
()),
getActions
:
()
=>
Promise
.
resolve
(
this
.
_getContextMenuActions
()),
getActionsContext
:
()
=>
this
.
_parentDomElement
});
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
浏览文件 @
48633183
...
...
@@ -7,7 +7,6 @@ import * as platform from 'vs/base/common/platform';
import
*
as
terminalEnvironment
from
'
vs/workbench/parts/terminal/node/terminalEnvironment
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ProcessState
,
ITerminalProcessManager
,
IShellLaunchConfig
,
ITerminalConfigHelper
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
...
...
@@ -32,7 +31,7 @@ const LAUNCHING_DURATION = 500;
*/
export
class
TerminalProcessManager
implements
ITerminalProcessManager
{
public
processState
:
ProcessState
=
ProcessState
.
UNINITIALIZED
;
public
ptyProcessReady
:
T
Promise
<
void
>
;
public
ptyProcessReady
:
Promise
<
void
>
;
public
shellProcessId
:
number
;
public
initialCwd
:
string
;
...
...
@@ -58,7 +57,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
@
IWorkspaceContextService
private
readonly
_workspaceContextService
:
IWorkspaceContextService
,
@
IConfigurationResolverService
private
readonly
_configurationResolverService
:
IConfigurationResolverService
)
{
this
.
ptyProcessReady
=
new
T
Promise
<
void
>
(
c
=>
{
this
.
ptyProcessReady
=
new
Promise
<
void
>
(
c
=>
{
this
.
onProcessReady
(()
=>
{
this
.
_logService
.
debug
(
`Terminal process ready (shellProcessId:
${
this
.
shellProcessId
}
)`
);
c
(
void
0
);
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
浏览文件 @
48633183
...
...
@@ -15,7 +15,6 @@ import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configur
import
{
ITerminalInstance
,
ITerminalService
,
IShellLaunchConfig
,
ITerminalConfigHelper
,
NEVER_SUGGEST_SELECT_WINDOWS_SHELL_STORAGE_KEY
,
TERMINAL_PANEL_ID
,
ITerminalProcessExtHostProxy
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
TerminalService
as
AbstractTerminalService
}
from
'
vs/workbench/parts/terminal/common/terminalService
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalConfigHelper
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
getDefaultShell
}
from
'
vs/workbench/parts/terminal/node/terminal
'
;
...
...
@@ -109,7 +108,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
});
}
public
focusFindWidget
():
T
Promise
<
void
>
{
public
focusFindWidget
():
Promise
<
void
>
{
return
this
.
showPanel
(
false
).
then
(()
=>
{
const
panel
=
this
.
_panelService
.
getActivePanel
()
as
TerminalPanel
;
panel
.
focusFindWidget
();
...
...
@@ -174,7 +173,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
run
:
()
=>
{
this
.
selectDefaultWindowsShell
().
then
(
shell
=>
{
if
(
!
shell
)
{
return
TPromise
.
as
(
null
);
return
Promise
.
resolve
(
null
);
}
// Launch a new instance with the newly selected shell
const
instance
=
this
.
createTerminal
({
...
...
@@ -184,7 +183,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
if
(
instance
)
{
this
.
setActiveInstance
(
instance
);
}
return
TPromise
.
as
(
null
);
return
Promise
.
resolve
(
null
);
});
}
},
...
...
@@ -196,7 +195,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
);
}
public
selectDefaultWindowsShell
():
T
Promise
<
string
>
{
public
selectDefaultWindowsShell
():
Promise
<
string
>
{
return
this
.
_detectWindowsShells
().
then
(
shells
=>
{
const
options
:
IPickOptions
<
IQuickPickItem
>
=
{
placeHolder
:
nls
.
localize
(
'
terminal.integrated.chooseWindowsShell
'
,
"
Select your preferred terminal shell, you can change this later in your settings
"
)
...
...
@@ -211,7 +210,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
});
}
private
_detectWindowsShells
():
T
Promise
<
IQuickPickItem
[]
>
{
private
_detectWindowsShells
():
Promise
<
IQuickPickItem
[]
>
{
// Determine the correct System32 path. We want to point to Sysnative
// when the 32-bit version of VS Code is running on a 64-bit machine.
// The reason for this is because PowerShell's important PSReadline
...
...
@@ -237,9 +236,9 @@ export class TerminalService extends AbstractTerminalService implements ITermina
`
${
process
.
env
[
'
LocalAppData
'
]}
\\Programs\\Git\\bin\\bash.exe`
,
]
};
const
promises
:
TPromis
e
<
[
string
,
string
]
>
[]
=
[];
const
promises
:
PromiseLik
e
<
[
string
,
string
]
>
[]
=
[];
Object
.
keys
(
expectedLocations
).
forEach
(
key
=>
promises
.
push
(
this
.
_validateShellPaths
(
key
,
expectedLocations
[
key
])));
return
TPromise
.
join
(
promises
).
then
(
results
=>
{
return
Promise
.
all
(
promises
).
then
(
results
=>
{
return
results
.
filter
(
result
=>
!!
result
).
map
(
result
=>
{
return
<
IQuickPickItem
>
{
label
:
result
[
0
],
...
...
@@ -249,7 +248,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
});
}
private
_validateShellPaths
(
label
:
string
,
potentialPaths
:
string
[]):
TPromis
e
<
[
string
,
string
]
>
{
private
_validateShellPaths
(
label
:
string
,
potentialPaths
:
string
[]):
PromiseLik
e
<
[
string
,
string
]
>
{
const
current
=
potentialPaths
.
shift
();
return
pfs
.
fileExists
(
current
).
then
(
exists
=>
{
if
(
!
exists
)
{
...
...
@@ -267,7 +266,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
return
activeInstance
?
activeInstance
:
this
.
createTerminal
(
undefined
,
wasNewTerminalAction
);
}
protected
_showTerminalCloseConfirmation
():
TPromis
e
<
boolean
>
{
protected
_showTerminalCloseConfirmation
():
PromiseLik
e
<
boolean
>
{
let
message
;
if
(
this
.
terminalInstances
.
length
===
1
)
{
message
=
nls
.
localize
(
'
terminalService.terminalCloseConfirmationSingular
'
,
"
There is an active terminal session, do you want to kill it?
"
);
...
...
src/vs/workbench/parts/terminal/node/windowsShellHelper.ts
浏览文件 @
48633183
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Emitter
,
debounceEvent
}
from
'
vs/base/common/event
'
;
import
{
ITerminalInstance
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
Terminal
as
XTermTerminal
}
from
'
vscode-xterm
'
;
...
...
@@ -26,9 +25,9 @@ const SHELL_EXECUTABLES = [
let
windowsProcessTree
:
typeof
WindowsProcessTreeType
;
export
class
WindowsShellHelper
{
private
_onCheckShell
:
Emitter
<
T
Promise
<
string
>>
;
private
_onCheckShell
:
Emitter
<
Promise
<
string
>>
;
private
_isDisposed
:
boolean
;
private
_currentRequest
:
T
Promise
<
string
>
;
private
_currentRequest
:
Promise
<
string
>
;
private
_newLineFeed
:
boolean
;
public
constructor
(
...
...
@@ -48,7 +47,7 @@ export class WindowsShellHelper {
}
windowsProcessTree
=
mod
;
this
.
_onCheckShell
=
new
Emitter
<
T
Promise
<
string
>>
();
this
.
_onCheckShell
=
new
Emitter
<
Promise
<
string
>>
();
// The debounce is necessary to prevent multiple processes from spawning when
// the enter key or output is spammed
debounceEvent
(
this
.
_onCheckShell
.
event
,
(
l
,
e
)
=>
e
,
150
,
true
)(()
=>
{
...
...
@@ -117,15 +116,15 @@ export class WindowsShellHelper {
/**
* Returns the innermost shell executable running in the terminal
*/
public
getShellName
():
T
Promise
<
string
>
{
public
getShellName
():
Promise
<
string
>
{
if
(
this
.
_isDisposed
)
{
return
TPromise
.
as
(
''
);
return
Promise
.
resolve
(
''
);
}
// Prevent multiple requests at once, instead return current request
if
(
this
.
_currentRequest
)
{
return
this
.
_currentRequest
;
}
this
.
_currentRequest
=
new
T
Promise
<
string
>
(
resolve
=>
{
this
.
_currentRequest
=
new
Promise
<
string
>
(
resolve
=>
{
windowsProcessTree
.
getProcessTree
(
this
.
_rootProcessId
,
(
tree
)
=>
{
const
name
=
this
.
traverseTree
(
tree
);
this
.
_currentRequest
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录