Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
70a890ef
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,发现更多精彩内容 >>
提交
70a890ef
编写于
4月 21, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make _workbench.openWith support other editor types
For #94408 Moves this out of custom editors
上级
38787b3f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
23 deletion
+37
-23
src/vs/workbench/api/browser/mainThreadEditors.ts
src/vs/workbench/api/browser/mainThreadEditors.ts
+25
-0
src/vs/workbench/contrib/customEditor/browser/commands.ts
src/vs/workbench/contrib/customEditor/browser/commands.ts
+0
-17
src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts
...h/contrib/customEditor/common/contributedCustomEditors.ts
+3
-2
src/vs/workbench/contrib/files/browser/fileActions.ts
src/vs/workbench/contrib/files/browser/fileActions.ts
+4
-4
src/vs/workbench/contrib/files/common/files.ts
src/vs/workbench/contrib/files/common/files.ts
+5
-0
未找到文件。
src/vs/workbench/api/browser/mainThreadEditors.ts
浏览文件 @
70a890ef
...
...
@@ -24,6 +24,7 @@ import { ExtHostContext, ExtHostEditorsShape, IApplyEditsOptions, IExtHostContex
import
{
EditorViewColumn
,
editorGroupToViewColumn
,
viewColumnToEditorGroup
}
from
'
vs/workbench/api/common/shared/editor
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
DEFAULT_EDITOR_ID
}
from
'
vs/workbench/contrib/files/common/files
'
;
export
class
MainThreadTextEditors
implements
MainThreadTextEditorsShape
{
...
...
@@ -293,6 +294,30 @@ CommandsRegistry.registerCommand('_workbench.open', function (accessor: Services
return
openerService
.
open
(
resource
).
then
(
_
=>
undefined
);
});
CommandsRegistry
.
registerCommand
(
'
_workbench.openWith
'
,
(
accessor
:
ServicesAccessor
,
args
:
[
URI
,
string
,
ITextEditorOptions
|
undefined
,
EditorViewColumn
|
undefined
])
=>
{
const
editorService
=
accessor
.
get
(
IEditorService
);
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
const
[
resource
,
id
,
options
,
position
]
=
args
;
const
group
=
editorGroupService
.
getGroup
(
viewColumnToEditorGroup
(
editorGroupService
,
position
))
??
editorGroupService
.
activeGroup
;
const
textOptions
=
options
?
{
...
options
,
ignoreOverrides
:
true
}
:
{
ignoreOverrides
:
true
};
const
fileEditorInput
=
editorService
.
createEditorInput
({
resource
,
forceFile
:
true
});
if
(
id
===
DEFAULT_EDITOR_ID
)
{
return
editorService
.
openEditor
(
fileEditorInput
,
textOptions
,
position
);
}
const
editors
=
editorService
.
getEditorOverrides
(
fileEditorInput
,
undefined
,
group
);
for
(
const
[
handler
,
data
]
of
editors
)
{
if
(
data
.
id
===
id
)
{
return
handler
.
open
(
fileEditorInput
,
options
,
group
,
id
);
}
}
return
undefined
;
});
CommandsRegistry
.
registerCommand
(
'
_workbench.diff
'
,
function
(
accessor
:
ServicesAccessor
,
args
:
[
URI
,
URI
,
string
,
string
,
IEditorOptions
,
EditorViewColumn
])
{
const
editorService
=
accessor
.
get
(
IEditorService
);
...
...
src/vs/workbench/contrib/customEditor/browser/commands.ts
浏览文件 @
70a890ef
...
...
@@ -4,33 +4,16 @@
*--------------------------------------------------------------------------------------------*/
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Command
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
InputFocusedContextKey
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
import
type
{
ITextEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
EditorViewColumn
,
viewColumnToEditorGroup
}
from
'
vs/workbench/api/common/shared/editor
'
;
import
{
CustomEditorInput
}
from
'
vs/workbench/contrib/customEditor/browser/customEditorInput
'
;
import
{
defaultCustomEditor
}
from
'
vs/workbench/contrib/customEditor/common/contributedCustomEditors
'
;
import
{
CONTEXT_CUSTOM_EDITORS
,
CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE
,
ICustomEditorService
}
from
'
vs/workbench/contrib/customEditor/common/customEditor
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
// #region Open With
CommandsRegistry
.
registerCommand
(
'
_workbench.openWith
'
,
(
accessor
:
ServicesAccessor
,
args
:
[
URI
,
string
,
ITextEditorOptions
|
undefined
,
EditorViewColumn
|
undefined
])
=>
{
const
customEditorService
=
accessor
.
get
(
ICustomEditorService
);
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
const
[
resource
,
viewType
,
options
,
position
]
=
args
;
const
group
=
viewColumnToEditorGroup
(
editorGroupService
,
position
);
customEditorService
.
openWith
(
resource
,
viewType
,
options
,
editorGroupService
.
getGroup
(
group
));
});
// #endregion
(
new
class
UndoCustomEditorCommand
extends
Command
{
public
static
readonly
ID
=
'
editor.action.customEditor.undo
'
;
...
...
src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts
浏览文件 @
70a890ef
...
...
@@ -9,12 +9,13 @@ import { URI } from 'vs/base/common/uri';
import
*
as
nls
from
'
vs/nls
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
CustomEditorInfo
,
CustomEditorPriority
}
from
'
vs/workbench/contrib/customEditor/common/customEditor
'
;
import
{
ICustomEditorsExtensionPoint
,
customEditorsExtensionPoint
}
from
'
vs/workbench/contrib/customEditor/common/extensionPoint
'
;
import
{
customEditorsExtensionPoint
,
ICustomEditorsExtensionPoint
}
from
'
vs/workbench/contrib/customEditor/common/extensionPoint
'
;
import
{
DEFAULT_EDITOR_ID
}
from
'
vs/workbench/contrib/files/common/files
'
;
const
builtinProviderDisplayName
=
nls
.
localize
(
'
builtinProviderDisplayName
'
,
"
Built-in
"
);
export
const
defaultCustomEditor
=
new
CustomEditorInfo
({
id
:
'
default
'
,
id
:
DEFAULT_EDITOR_ID
,
displayName
:
nls
.
localize
(
'
promptOpenWith.defaultEditor.displayName
'
,
"
Text Editor
"
),
providerDisplayName
:
builtinProviderDisplayName
,
selector
:
[
...
...
src/vs/workbench/contrib/files/browser/fileActions.ts
浏览文件 @
70a890ef
...
...
@@ -13,7 +13,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
VIEWLET_ID
,
IExplorerService
,
IFilesConfiguration
}
from
'
vs/workbench/contrib/files/common/files
'
;
import
{
VIEWLET_ID
,
IExplorerService
,
IFilesConfiguration
,
DEFAULT_EDITOR_ID
}
from
'
vs/workbench/contrib/files/common/files
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
toResource
,
SideBySideEditor
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
...
...
@@ -576,9 +576,9 @@ export class ReopenResourcesAction extends Action {
return
;
}
if
(
!
items
.
find
(
item
=>
item
.
id
===
'
default
'
))
{
if
(
!
items
.
find
(
item
=>
item
.
id
===
DEFAULT_EDITOR_ID
))
{
items
.
unshift
({
id
:
'
default
'
,
id
:
DEFAULT_EDITOR_ID
,
label
:
nls
.
localize
(
'
promptOpenWith.defaultEditor.displayName
'
,
"
Text Editor
"
),
description
:
activeInput
instanceof
FileEditorInput
?
'
Currently Active
'
:
undefined
,
detail
:
builtinProviderDisplayName
,
...
...
@@ -633,7 +633,7 @@ export class ReopenResourcesAction extends Action {
return
;
}
if
(
pickedItem
.
id
===
'
default
'
)
{
if
(
pickedItem
.
id
===
DEFAULT_EDITOR_ID
)
{
const
fileEditorInput
=
this
.
editorService
.
createEditorInput
({
resource
:
activeResource
!
,
forceFile
:
true
});
const
textOptions
=
options
?
{
...
options
,
ignoreOverrides
:
true
}
:
{
ignoreOverrides
:
true
};
...
...
src/vs/workbench/contrib/files/common/files.ts
浏览文件 @
70a890ef
...
...
@@ -29,6 +29,11 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
*/
export
const
VIEWLET_ID
=
'
workbench.view.explorer
'
;
/**
* Id of the default editor for open with.
*/
export
const
DEFAULT_EDITOR_ID
=
'
default
'
;
export
interface
IExplorerService
{
_serviceBrand
:
undefined
;
readonly
roots
:
ExplorerItem
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录