Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
03262df5
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,发现更多精彩内容 >>
提交
03262df5
编写于
12月 18, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #40333
上级
9812d210
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
69 addition
and
85 deletion
+69
-85
src/vs/workbench/browser/parts/editor/editorPicker.ts
src/vs/workbench/browser/parts/editor/editorPicker.ts
+8
-6
src/vs/workbench/services/history/electron-browser/history.ts
...vs/workbench/services/history/electron-browser/history.ts
+61
-79
未找到文件。
src/vs/workbench/browser/parts/editor/editorPicker.ts
浏览文件 @
03262df5
...
...
@@ -16,7 +16,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
{
getIconClasses
}
from
'
vs/workbench/browser/labels
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
QuickOpenHandler
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
Position
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -71,13 +71,15 @@ export class EditorPickerEntry extends QuickOpenEntryGroup {
}
public
run
(
mode
:
Mode
,
context
:
IEntryRunContext
):
boolean
{
let
options
:
IEditorOptions
;
if
(
mode
===
Mode
.
PREVIEW
)
{
options
=
{
preserveFocus
:
true
};
// in preview, make sure to keep focus in quick open
if
(
mode
===
Mode
.
OPEN
)
{
return
this
.
runOpen
(
context
);
}
// Open Editor
this
.
editorService
.
openEditor
(
this
.
editor
,
options
,
this
.
stacks
.
positionOfGroup
(
this
.
group
)).
done
(
null
,
errors
.
onUnexpectedError
);
return
super
.
run
(
mode
,
context
);
}
private
runOpen
(
context
:
IEntryRunContext
):
boolean
{
this
.
editorService
.
openEditor
(
this
.
editor
,
null
,
this
.
stacks
.
positionOfGroup
(
this
.
group
)).
done
(
null
,
errors
.
onUnexpectedError
);
return
true
;
}
...
...
src/vs/workbench/services/history/electron-browser/history.ts
浏览文件 @
03262df5
...
...
@@ -89,76 +89,6 @@ interface IEditorIdentifier {
position
:
GroupPosition
;
}
export
abstract
class
BaseHistoryService
{
protected
toUnbind
:
IDisposable
[];
private
activeEditorListeners
:
IDisposable
[];
private
lastActiveEditor
:
IEditorIdentifier
;
constructor
(
protected
editorGroupService
:
IEditorGroupService
,
protected
editorService
:
IWorkbenchEditorService
)
{
this
.
toUnbind
=
[];
this
.
activeEditorListeners
=
[];
// Listeners
this
.
toUnbind
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorsChanged
()));
}
private
onEditorsChanged
():
void
{
const
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
this
.
lastActiveEditor
&&
this
.
matchesEditor
(
this
.
lastActiveEditor
,
activeEditor
))
{
return
;
// return if the active editor is still the same
}
// Remember as last active editor (can be undefined if none opened)
this
.
lastActiveEditor
=
activeEditor
?
{
editor
:
activeEditor
.
input
,
position
:
activeEditor
.
position
}
:
void
0
;
// Dispose old listeners
dispose
(
this
.
activeEditorListeners
);
this
.
activeEditorListeners
=
[];
// Propagate to history
this
.
handleActiveEditorChange
(
activeEditor
);
// Apply listener for selection changes if this is a text editor
const
control
=
getCodeEditor
(
activeEditor
);
if
(
control
)
{
// Debounce the event with a timeout of 0ms so that multiple calls to
// editor.setSelection() are folded into one. We do not want to record
// subsequent history navigations for such API calls.
this
.
activeEditorListeners
.
push
(
debounceEvent
(
control
.
onDidChangeCursorPosition
,
(
last
,
event
)
=>
event
,
0
)((
event
=>
{
this
.
handleEditorSelectionChangeEvent
(
activeEditor
,
event
);
})));
}
}
private
matchesEditor
(
identifier
:
IEditorIdentifier
,
editor
?:
IBaseEditor
):
boolean
{
if
(
!
editor
)
{
return
false
;
}
if
(
identifier
.
position
!==
editor
.
position
)
{
return
false
;
}
return
identifier
.
editor
.
matches
(
editor
.
input
);
}
protected
abstract
handleExcludesChange
():
void
;
protected
abstract
handleEditorSelectionChangeEvent
(
editor
?:
IBaseEditor
,
event
?:
ICursorPositionChangedEvent
):
void
;
protected
abstract
handleActiveEditorChange
(
editor
?:
IBaseEditor
):
void
;
public
dispose
():
void
{
this
.
toUnbind
=
dispose
(
this
.
toUnbind
);
}
}
interface
IStackEntry
{
input
:
IEditorInput
|
IResourceInput
;
selection
?:
ITextEditorSelection
;
...
...
@@ -170,7 +100,7 @@ interface IRecentlyClosedFile {
index
:
number
;
}
export
class
HistoryService
extends
BaseHistoryService
implements
IHistoryService
{
export
class
HistoryService
implements
IHistoryService
{
public
_serviceBrand
:
any
;
...
...
@@ -179,6 +109,11 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
private
static
readonly
MAX_STACK_ITEMS
=
20
;
private
static
readonly
MAX_RECENTLY_CLOSED_EDITORS
=
20
;
private
toUnbind
:
IDisposable
[];
private
activeEditorListeners
:
IDisposable
[];
private
lastActiveEditor
:
IEditorIdentifier
;
private
stack
:
IStackEntry
[];
private
index
:
number
;
private
lastIndex
:
number
;
...
...
@@ -191,8 +126,8 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
private
resourceFilter
:
ResourceGlobMatcher
;
constructor
(
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
...
...
@@ -201,7 +136,8 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
@
IWindowsService
private
windowService
:
IWindowsService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
)
{
super
(
editorGroupService
,
editorService
);
this
.
toUnbind
=
[];
this
.
activeEditorListeners
=
[];
this
.
index
=
-
1
;
this
.
lastIndex
=
-
1
;
...
...
@@ -217,11 +153,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this
.
registerListeners
();
}
private
setIndex
(
value
:
number
):
void
{
this
.
lastIndex
=
this
.
index
;
this
.
index
=
value
;
}
private
getExcludes
(
root
?:
URI
):
IExpression
{
const
scope
=
root
?
{
resource
:
root
}
:
void
0
;
...
...
@@ -229,6 +160,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
}
private
registerListeners
():
void
{
this
.
toUnbind
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorsChanged
()));
this
.
toUnbind
.
push
(
this
.
lifecycleService
.
onShutdown
(
reason
=>
this
.
saveHistory
()));
this
.
toUnbind
.
push
(
this
.
editorGroupService
.
onEditorOpenFail
(
editor
=>
this
.
remove
(
editor
)));
this
.
toUnbind
.
push
(
this
.
editorGroupService
.
getStacksModel
().
onEditorClosed
(
event
=>
this
.
onEditorClosed
(
event
)));
...
...
@@ -236,6 +168,47 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this
.
toUnbind
.
push
(
this
.
resourceFilter
.
onExpressionChange
(()
=>
this
.
handleExcludesChange
()));
}
private
onEditorsChanged
():
void
{
const
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
this
.
lastActiveEditor
&&
this
.
matchesEditor
(
this
.
lastActiveEditor
,
activeEditor
))
{
return
;
// return if the active editor is still the same
}
// Remember as last active editor (can be undefined if none opened)
this
.
lastActiveEditor
=
activeEditor
?
{
editor
:
activeEditor
.
input
,
position
:
activeEditor
.
position
}
:
void
0
;
// Dispose old listeners
dispose
(
this
.
activeEditorListeners
);
this
.
activeEditorListeners
=
[];
// Propagate to history
this
.
handleActiveEditorChange
(
activeEditor
);
// Apply listener for selection changes if this is a text editor
const
control
=
getCodeEditor
(
activeEditor
);
if
(
control
)
{
// Debounce the event with a timeout of 0ms so that multiple calls to
// editor.setSelection() are folded into one. We do not want to record
// subsequent history navigations for such API calls.
this
.
activeEditorListeners
.
push
(
debounceEvent
(
control
.
onDidChangeCursorPosition
,
(
last
,
event
)
=>
event
,
0
)((
event
=>
{
this
.
handleEditorSelectionChangeEvent
(
activeEditor
,
event
);
})));
}
}
private
matchesEditor
(
identifier
:
IEditorIdentifier
,
editor
?:
IBaseEditor
):
boolean
{
if
(
!
editor
)
{
return
false
;
}
if
(
identifier
.
position
!==
editor
.
position
)
{
return
false
;
}
return
identifier
.
editor
.
matches
(
editor
.
input
);
}
private
onFileChanges
(
e
:
FileChangesEvent
):
void
{
if
(
e
.
gotDeleted
())
{
this
.
remove
(
e
);
// remove from history files that got deleted or moved
...
...
@@ -292,6 +265,11 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this
.
navigate
();
}
private
setIndex
(
value
:
number
):
void
{
this
.
lastIndex
=
this
.
index
;
this
.
index
=
value
;
}
private
doForwardAcrossEditors
():
void
{
let
currentIndex
=
this
.
index
;
const
currentEntry
=
this
.
stack
[
this
.
index
];
...
...
@@ -840,4 +818,8 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
return
void
0
;
}
public
dispose
():
void
{
this
.
toUnbind
=
dispose
(
this
.
toUnbind
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录