Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c4aabc56
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,发现更多精彩内容 >>
提交
c4aabc56
编写于
6月 20, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
multi root - introduce and use new method to retrieve last active file workspace
上级
f066fd48
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
70 addition
and
31 deletion
+70
-31
src/vs/workbench/parts/execution/electron-browser/terminal.contribution.ts
...parts/execution/electron-browser/terminal.contribution.ts
+5
-3
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+12
-10
src/vs/workbench/services/history/browser/history.ts
src/vs/workbench/services/history/browser/history.ts
+23
-0
src/vs/workbench/services/history/common/history.ts
src/vs/workbench/services/history/common/history.ts
+7
-0
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+16
-14
src/vs/workbench/services/textfile/electron-browser/textFileService.ts
...nch/services/textfile/electron-browser/textFileService.ts
+4
-2
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+3
-2
未找到文件。
src/vs/workbench/parts/execution/electron-browser/terminal.contribution.ts
浏览文件 @
c4aabc56
...
...
@@ -24,6 +24,7 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import
{
Extensions
,
IConfigurationRegistry
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
DEFAULT_TERMINAL_WINDOWS
,
DEFAULT_TERMINAL_LINUX_READY
,
DEFAULT_TERMINAL_OSX
}
from
'
vs/workbench/parts/execution/electron-browser/terminal
'
;
import
{
IHistoryService
}
from
"
vs/workbench/services/history/common/history
"
;
DEFAULT_TERMINAL_LINUX_READY
.
then
(
defaultTerminalLinux
=>
{
let
configurationRegistry
=
<
IConfigurationRegistry
>
Registry
.
as
(
Extensions
.
Configuration
);
...
...
@@ -70,7 +71,8 @@ export class OpenConsoleAction extends Action {
label
:
string
,
@
ITerminalService
private
terminalService
:
ITerminalService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IHistoryService
private
historyService
:
IHistoryService
)
{
super
(
id
,
label
);
...
...
@@ -86,8 +88,8 @@ export class OpenConsoleAction extends Action {
let
pathToOpen
:
string
;
// Try workspace path first
let
workspace
=
this
.
contextService
.
getWorkspace
();
pathToOpen
=
this
.
resource
?
this
.
resource
.
fsPath
:
(
workspace
&&
workspace
.
resource
.
fsPath
);
const
root
=
this
.
historyService
.
getLastActiveWorkspaceRoot
();
pathToOpen
=
this
.
resource
?
this
.
resource
.
fsPath
:
(
root
&&
root
.
fsPath
);
// Otherwise check if we have an active file open
if
(
!
pathToOpen
)
{
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
c4aabc56
...
...
@@ -21,7 +21,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
ITerminalInstance
,
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
,
TERMINAL_PANEL_ID
,
IShellLaunchConfig
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
ITerminalProcessFactory
}
from
'
vs/workbench/parts/terminal/electron-browser/terminal
'
;
import
{
I
LegacyWorkspace
,
I
WorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
...
...
@@ -33,6 +33,7 @@ import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platf
import
{
scrollbarSliderBackground
,
scrollbarSliderHoverBackground
,
scrollbarSliderActiveBackground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
IHistoryService
}
from
"
vs/workbench/services/history/common/history
"
;
/** The amount of time to consider terminal errors to be related to the launch */
const
LAUNCHING_DURATION
=
500
;
...
...
@@ -102,7 +103,8 @@ export class TerminalInstance implements ITerminalInstance {
@
IWorkspaceContextService
private
_contextService
:
IWorkspaceContextService
,
@
IWorkbenchEditorService
private
_editorService
:
IWorkbenchEditorService
,
@
IInstantiationService
private
_instantiationService
:
IInstantiationService
,
@
IClipboardService
private
_clipboardService
:
IClipboardService
@
IClipboardService
private
_clipboardService
:
IClipboardService
,
@
IHistoryService
private
_historyService
:
IHistoryService
)
{
this
.
_instanceDisposables
=
[];
this
.
_processDisposables
=
[];
...
...
@@ -126,7 +128,7 @@ export class TerminalInstance implements ITerminalInstance {
});
this
.
_initDimensions
();
this
.
_createProcess
(
this
.
_
contextService
.
getWorkspace
(),
this
.
_shellLaunchConfig
);
this
.
_createProcess
(
this
.
_
historyService
.
getLastActiveWorkspaceRoot
(),
this
.
_shellLaunchConfig
);
this
.
_createXterm
();
// Only attach xterm.js to the DOM if the terminal panel has been opened before.
...
...
@@ -464,7 +466,7 @@ export class TerminalInstance implements ITerminalInstance {
return
typeof
data
===
'
string
'
?
data
.
replace
(
TerminalInstance
.
WINDOWS_EOL_REGEX
,
'
\r
'
)
:
data
;
}
protected
_getCwd
(
shell
:
IShellLaunchConfig
,
workspace
:
ILegacyWorkspace
):
string
{
protected
_getCwd
(
shell
:
IShellLaunchConfig
,
root
:
Uri
):
string
{
if
(
shell
.
cwd
)
{
return
shell
.
cwd
;
}
...
...
@@ -478,26 +480,26 @@ export class TerminalInstance implements ITerminalInstance {
if
(
customCwd
)
{
if
(
path
.
isAbsolute
(
customCwd
))
{
cwd
=
customCwd
;
}
else
if
(
workspace
)
{
cwd
=
path
.
normalize
(
path
.
join
(
workspace
.
resource
.
fsPath
,
customCwd
));
}
else
if
(
root
)
{
cwd
=
path
.
normalize
(
path
.
join
(
root
.
fsPath
,
customCwd
));
}
}
}
// If there was no custom cwd or it was relative with no workspace
if
(
!
cwd
)
{
cwd
=
workspace
?
workspace
.
resource
.
fsPath
:
os
.
homedir
();
cwd
=
root
?
root
.
fsPath
:
os
.
homedir
();
}
return
TerminalInstance
.
_sanitizeCwd
(
cwd
);
}
protected
_createProcess
(
workspace
:
ILegacyWorkspace
,
shell
:
IShellLaunchConfig
):
void
{
protected
_createProcess
(
root
:
Uri
,
shell
:
IShellLaunchConfig
):
void
{
const
locale
=
this
.
_configHelper
.
config
.
setLocaleVariables
?
platform
.
locale
:
undefined
;
if
(
!
shell
.
executable
)
{
this
.
_configHelper
.
mergeDefaultShellPathAndArgs
(
shell
);
}
const
env
=
TerminalInstance
.
createTerminalEnv
(
process
.
env
,
shell
,
this
.
_getCwd
(
shell
,
workspace
),
locale
,
this
.
_cols
,
this
.
_rows
);
const
env
=
TerminalInstance
.
createTerminalEnv
(
process
.
env
,
shell
,
this
.
_getCwd
(
shell
,
root
),
locale
,
this
.
_cols
,
this
.
_rows
);
this
.
_title
=
shell
.
name
||
''
;
this
.
_process
=
cp
.
fork
(
Uri
.
parse
(
require
.
toUrl
(
'
bootstrap
'
)).
fsPath
,
[
'
--type=terminal
'
],
{
env
,
...
...
@@ -620,7 +622,7 @@ export class TerminalInstance implements ITerminalInstance {
// Initialize new process
const
oldTitle
=
this
.
_title
;
this
.
_createProcess
(
this
.
_
contextService
.
getWorkspace
(),
shell
);
this
.
_createProcess
(
this
.
_
historyService
.
getLastActiveWorkspaceRoot
(),
shell
);
if
(
oldTitle
!==
this
.
_title
)
{
this
.
_onTitleChanged
.
fire
(
this
.
_title
);
}
...
...
src/vs/workbench/services/history/browser/history.ts
浏览文件 @
c4aabc56
...
...
@@ -696,4 +696,27 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
return
void
0
;
}).
filter
(
input
=>
!!
input
);
}
public
getLastActiveWorkspaceRoot
():
URI
{
if
(
!
this
.
contextService
.
hasWorkspace
())
{
return
void
0
;
}
const
history
=
this
.
getHistory
();
for
(
let
i
=
0
;
i
<
history
.
length
;
i
++
)
{
const
input
=
history
[
i
];
if
(
input
instanceof
EditorInput
)
{
continue
;
}
const
resourceInput
=
input
as
IResourceInput
;
const
resourceWorkspace
=
this
.
contextService
.
getRoot
(
resourceInput
.
resource
);
if
(
resourceWorkspace
)
{
return
resourceWorkspace
;
}
}
// fallback to first workspace
return
this
.
contextService
.
getWorkspace2
().
roots
[
0
];
}
}
src/vs/workbench/services/history/common/history.ts
浏览文件 @
c4aabc56
...
...
@@ -6,6 +6,7 @@
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorInput
,
ITextEditorOptions
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
URI
from
"
vs/base/common/uri
"
;
export
const
IHistoryService
=
createDecorator
<
IHistoryService
>
(
'
historyService
'
);
...
...
@@ -53,4 +54,10 @@ export interface IHistoryService {
* Get the entire history of opened editors.
*/
getHistory
():
(
IEditorInput
|
IResourceInput
)[];
/**
* Looking at the editor history, returns the workspace root of the last file that was
* inside the workspace and part of the editor history.
*/
getLastActiveWorkspaceRoot
():
URI
;
}
\ No newline at end of file
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
c4aabc56
...
...
@@ -30,6 +30,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
Schemas
}
from
"
vs/base/common/network
"
;
import
{
IHistoryService
}
from
"
vs/workbench/services/history/common/history
"
;
export
interface
IBackupResult
{
didBackup
:
boolean
;
...
...
@@ -58,17 +59,18 @@ export abstract class TextFileService implements ITextFileService {
private
configuredHotExit
:
string
;
constructor
(
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IFileService
protected
fileService
:
IFileService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IMessageService
private
messageService
:
IMessageService
,
@
IEnvironmentService
protected
environmentService
:
IEnvironmentService
,
@
IBackupFileService
private
backupFileService
:
IBackupFileService
,
@
IWindowsService
private
windowsService
:
IWindowsService
private
lifecycleService
:
ILifecycleService
,
private
contextService
:
IWorkspaceContextService
,
private
configurationService
:
IConfigurationService
,
private
telemetryService
:
ITelemetryService
,
protected
fileService
:
IFileService
,
private
untitledEditorService
:
IUntitledEditorService
,
private
instantiationService
:
IInstantiationService
,
private
messageService
:
IMessageService
,
protected
environmentService
:
IEnvironmentService
,
private
backupFileService
:
IBackupFileService
,
private
windowsService
:
IWindowsService
,
private
historyService
:
IHistoryService
)
{
this
.
toUnbind
=
[];
...
...
@@ -609,9 +611,9 @@ export abstract class TextFileService implements ITextFileService {
}
private
suggestFileName
(
untitledResource
:
URI
):
string
{
const
workspace
=
this
.
contextService
.
getWorkspace
();
if
(
workspace
)
{
return
URI
.
file
(
paths
.
join
(
workspace
.
resource
.
fsPath
,
this
.
untitledEditorService
.
suggestFileName
(
untitledResource
))).
fsPath
;
const
root
=
this
.
historyService
.
getLastActiveWorkspaceRoot
();
if
(
root
)
{
return
URI
.
file
(
paths
.
join
(
root
.
fsPath
,
this
.
untitledEditorService
.
suggestFileName
(
untitledResource
))).
fsPath
;
}
return
this
.
untitledEditorService
.
suggestFileName
(
untitledResource
);
...
...
src/vs/workbench/services/textfile/electron-browser/textFileService.ts
浏览文件 @
c4aabc56
...
...
@@ -29,6 +29,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
IWindowsService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IHistoryService
}
from
"
vs/workbench/services/history/common/history
"
;
export
class
TextFileService
extends
AbstractTextFileService
{
...
...
@@ -47,9 +48,10 @@ export class TextFileService extends AbstractTextFileService {
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IMessageService
messageService
:
IMessageService
,
@
IBackupFileService
backupFileService
:
IBackupFileService
,
@
IWindowsService
windowsService
:
IWindowsService
@
IWindowsService
windowsService
:
IWindowsService
,
@
IHistoryService
historyService
:
IHistoryService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
environmentService
,
backupFileService
,
windowsService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
environmentService
,
backupFileService
,
windowsService
,
historyService
);
}
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
c4aabc56
...
...
@@ -156,9 +156,10 @@ export class TestTextFileService extends TextFileService {
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
,
@
IBackupFileService
backupFileService
:
IBackupFileService
,
@
IWindowsService
windowsService
:
IWindowsService
@
IWindowsService
windowsService
:
IWindowsService
,
@
IHistoryService
historyService
:
IHistoryService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
TestEnvironmentService
,
backupFileService
,
windowsService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
TestEnvironmentService
,
backupFileService
,
windowsService
,
historyService
);
}
public
setPromptPath
(
path
:
string
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录