Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c952dafd
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,发现更多精彩内容 >>
提交
c952dafd
编写于
5月 16, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - lift activeTextEditorControl to text editor service
上级
7a6f19c6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
42 addition
and
13 deletion
+42
-13
src/vs/editor/browser/controller/coreCommands.ts
src/vs/editor/browser/controller/coreCommands.ts
+15
-6
src/vs/editor/browser/editorExtensions.ts
src/vs/editor/browser/editorExtensions.ts
+16
-7
src/vs/editor/browser/services/textEditorService.ts
src/vs/editor/browser/services/textEditorService.ts
+6
-0
src/vs/editor/standalone/browser/simpleServices.ts
src/vs/editor/standalone/browser/simpleServices.ts
+4
-0
src/vs/editor/test/browser/services/openerService.test.ts
src/vs/editor/test/browser/services/openerService.test.ts
+1
-0
未找到文件。
src/vs/editor/browser/controller/coreCommands.ts
浏览文件 @
c952dafd
...
...
@@ -18,7 +18,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
H
=
editorCommon
.
Handler
;
import
{
ICodeEditorService
,
getCodeEditor
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
...
...
@@ -26,7 +26,7 @@ import { ITextEditorService } from 'vs/editor/browser/services/textEditorService
import
{
TypeOperations
}
from
'
vs/editor/common/controller/cursorTypeOperations
'
;
import
{
DeleteOperations
}
from
'
vs/editor/common/controller/cursorDeleteOperations
'
;
import
{
VerticalRevealType
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
const
CORE_WEIGHT
=
KeybindingsRegistry
.
WEIGHT
.
editorCore
();
...
...
@@ -1620,10 +1620,19 @@ function findFocusedEditor(accessor: ServicesAccessor): ICodeEditor {
return
accessor
.
get
(
ICodeEditorService
).
getFocusedCodeEditor
();
}
function
get
Workbench
ActiveEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
{
function
getActiveEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
{
const
editorService
=
accessor
.
get
(
ITextEditorService
);
let
activeEditor
=
(
<
any
>
editorService
).
getActiveEditor
&&
(
<
any
>
editorService
).
getActiveEditor
();
return
getCodeEditor
(
activeEditor
);
let
activeEditor
=
editorService
.
activeTextEditorControl
;
if
(
isCodeEditor
(
activeEditor
))
{
return
activeEditor
;
}
if
(
isDiffEditor
(
activeEditor
))
{
return
activeEditor
.
getModifiedEditor
();
}
return
null
;
}
function
registerCommand
(
command
:
Command
)
{
...
...
@@ -1663,7 +1672,7 @@ class EditorOrNativeTextInputCommand extends Command {
}
// Redirecting to last active editor
let
activeEditor
=
get
Workbench
ActiveEditor
(
accessor
);
let
activeEditor
=
getActiveEditor
(
accessor
);
if
(
activeEditor
)
{
activeEditor
.
focus
();
return
this
.
_runEditorHandler
(
activeEditor
,
args
);
...
...
src/vs/editor/browser/editorExtensions.ts
浏览文件 @
c952dafd
...
...
@@ -18,8 +18,8 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
MenuId
,
MenuRegistry
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICodeEditorService
,
getCodeEditor
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ICodeEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
export
type
ServicesAccessor
=
ServicesAccessor
;
...
...
@@ -85,10 +85,19 @@ export abstract class Command {
//#region EditorCommand
function
get
Workbench
ActiveEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
{
function
getActiveEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
{
const
editorService
=
accessor
.
get
(
ITextEditorService
);
let
activeEditor
=
(
<
any
>
editorService
).
getActiveEditor
&&
(
<
any
>
editorService
).
getActiveEditor
();
return
getCodeEditor
(
activeEditor
);
let
activeEditor
=
editorService
.
activeTextEditorControl
;
if
(
isCodeEditor
(
activeEditor
))
{
return
activeEditor
;
}
if
(
isDiffEditor
(
activeEditor
))
{
return
activeEditor
.
getModifiedEditor
();
}
return
null
;
}
export
interface
IContributionCommandOptions
<
T
>
extends
ICommandOptions
{
...
...
@@ -128,8 +137,8 @@ export abstract class EditorCommand extends Command {
let
editor
=
codeEditorService
.
getFocusedCodeEditor
();
if
(
!
editor
)
{
// Fallback to use
what the workbench considers
the active editor
editor
=
get
Workbench
ActiveEditor
(
accessor
);
// Fallback to use the active editor
editor
=
getActiveEditor
(
accessor
);
}
if
(
!
editor
)
{
...
...
src/vs/editor/browser/services/textEditorService.ts
浏览文件 @
c952dafd
...
...
@@ -8,6 +8,7 @@
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
export
const
ITextEditorService
=
createDecorator
<
ITextEditorService
>
(
'
textEditorService
'
);
...
...
@@ -15,6 +16,11 @@ export interface ITextEditorService {
_serviceBrand
:
ServiceIdentifier
<
ITextEditorService
>
;
/**
* The currently active text editor or `null` if none.
*/
readonly
activeTextEditorControl
:
IEditor
;
/**
* Open a text editor.
*/
...
...
src/vs/editor/standalone/browser/simpleServices.ts
浏览文件 @
c952dafd
...
...
@@ -100,6 +100,10 @@ export class SimpleEditorService implements ITextEditorService {
this
.
openEditorDelegate
=
null
;
}
get
activeTextEditorControl
():
editorCommon
.
IEditor
{
return
null
;
}
public
setEditor
(
editor
:
editorCommon
.
IEditor
):
void
{
this
.
editor
=
editor
;
}
...
...
src/vs/editor/test/browser/services/openerService.test.ts
浏览文件 @
c952dafd
...
...
@@ -18,6 +18,7 @@ suite('OpenerService', function () {
const
editorService
=
new
class
implements
ITextEditorService
{
_serviceBrand
:
any
;
activeTextEditorControl
:
null
;
openTextEditor
(
input
:
IResourceInput
):
any
{
lastInput
=
input
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录