Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
605b95d3
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,体验更适合开发者的 AI 搜索 >>
提交
605b95d3
编写于
9月 25, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
convert diff actions to commands (for #59346)
上级
a5580c3d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
90 deletion
+64
-90
src/vs/workbench/browser/parts/editor/editor.contribution.ts
src/vs/workbench/browser/parts/editor/editor.contribution.ts
+58
-25
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+5
-2
src/vs/workbench/browser/parts/editor/media/textdiffeditor.css
...s/workbench/browser/parts/editor/media/textdiffeditor.css
+0
-18
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
+1
-45
未找到文件。
src/vs/workbench/browser/parts/editor/editor.contribution.ts
浏览文件 @
605b95d3
...
...
@@ -12,7 +12,7 @@ import { IEditorQuickOpenEntry, IQuickOpenRegistry, Extensions as QuickOpenExten
import
{
StatusbarItemDescriptor
,
IStatusbarRegistry
,
Extensions
as
StatusExtensions
}
from
'
vs/workbench/browser/parts/statusbar/statusbar
'
;
import
{
StatusbarAlignment
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
IEditorRegistry
,
EditorDescriptor
,
Extensions
as
EditorExtensions
}
from
'
vs/workbench/browser/editor
'
;
import
{
EditorInput
,
IEditorInputFactory
,
SideBySideEditorInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
,
IEditorInputFactory
,
SideBySideEditorInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
,
TextCompareEditorActiveContext
}
from
'
vs/workbench/common/editor
'
;
import
{
TextResourceEditor
}
from
'
vs/workbench/browser/parts/editor/textResourceEditor
'
;
import
{
SideBySideEditor
}
from
'
vs/workbench/browser/parts/editor/sideBySideEditor
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
...
...
@@ -25,7 +25,7 @@ import { BinaryResourceDiffEditor } from 'vs/workbench/browser/parts/editor/bina
import
{
ChangeEncodingAction
,
ChangeEOLAction
,
ChangeModeAction
,
EditorStatus
}
from
'
vs/workbench/browser/parts/editor/editorStatus
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actions
'
;
import
{
Scope
,
IActionBarRegistry
,
Extensions
as
ActionBarExtensions
,
ActionBarContributor
}
from
'
vs/workbench/browser/actions
'
;
import
{
SyncActionDescriptor
,
MenuRegistry
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
SyncActionDescriptor
,
MenuRegistry
,
MenuId
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
KeyMod
,
KeyChord
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
...
...
@@ -443,8 +443,8 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.
interface
IEditorToolItem
{
id
:
string
;
title
:
string
;
iconDark
:
string
;
iconLight
:
string
;
}
function
appendEditorToolItem
(
primary
:
IEditorToolItem
,
alternative
:
IEditorToolItem
,
when
:
ContextKeyExpr
,
order
:
number
):
void
{
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
function
appendEditorToolItem
(
primary
:
IEditorToolItem
,
when
:
ContextKeyExpr
,
order
:
number
,
alternative
?:
IEditorToolItem
):
void
{
const
item
:
IMenuItem
=
{
command
:
{
id
:
primary
.
id
,
title
:
primary
.
title
,
...
...
@@ -453,18 +453,23 @@ function appendEditorToolItem(primary: IEditorToolItem, alternative: IEditorTool
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
primary
.
iconLight
}
`
))
}
},
alt
:
{
group
:
'
navigation
'
,
when
,
order
};
if
(
alternative
)
{
item
.
alt
=
{
id
:
alternative
.
id
,
title
:
alternative
.
title
,
iconLocation
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
alternative
.
iconDark
}
`
)),
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
alternative
.
iconLight
}
`
))
}
},
group
:
'
navigation
'
,
when
,
order
});
};
}
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
item
);
}
// Editor Title Menu: Split Editor
...
...
@@ -474,14 +479,15 @@ appendEditorToolItem(
title
:
nls
.
localize
(
'
splitEditorRight
'
,
"
Split Editor Right
"
),
iconDark
:
'
split-editor-horizontal-inverse.svg
'
,
iconLight
:
'
split-editor-horizontal.svg
'
},
{
},
ContextKeyExpr
.
not
(
'
splitEditorsVertically
'
),
100000
,
// towards the end
{
id
:
editorCommands
.
SPLIT_EDITOR_DOWN
,
title
:
nls
.
localize
(
'
splitEditorDown
'
,
"
Split Editor Down
"
),
iconDark
:
'
split-editor-vertical-inverse.svg
'
,
iconLight
:
'
split-editor-vertical.svg
'
},
ContextKeyExpr
.
not
(
'
splitEditorsVertically
'
),
100000
/* towards the end */
}
);
appendEditorToolItem
(
...
...
@@ -490,14 +496,15 @@ appendEditorToolItem(
title
:
nls
.
localize
(
'
splitEditorDown
'
,
"
Split Editor Down
"
),
iconDark
:
'
split-editor-vertical-inverse.svg
'
,
iconLight
:
'
split-editor-vertical.svg
'
},
{
},
ContextKeyExpr
.
has
(
'
splitEditorsVertically
'
),
100000
,
// towards the end
{
id
:
editorCommands
.
SPLIT_EDITOR_RIGHT
,
title
:
nls
.
localize
(
'
splitEditorRight
'
,
"
Split Editor Right
"
),
iconDark
:
'
split-editor-horizontal-inverse.svg
'
,
iconLight
:
'
split-editor-horizontal.svg
'
},
ContextKeyExpr
.
has
(
'
splitEditorsVertically
'
),
100000
// towards the end
}
);
// Editor Title Menu: Close Group (tabs disabled)
...
...
@@ -507,14 +514,15 @@ appendEditorToolItem(
title
:
nls
.
localize
(
'
close
'
,
"
Close
"
),
iconDark
:
'
close-big-inverse-alt.svg
'
,
iconLight
:
'
close-big-alt.svg
'
},
{
},
ContextKeyExpr
.
and
(
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
ContextKeyExpr
.
not
(
'
groupActiveEditorDirty
'
)),
1000000
,
// towards the far end
{
id
:
editorCommands
.
CLOSE_EDITORS_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeAll
'
,
"
Close All
"
),
iconDark
:
'
closeall-editors-inverse.svg
'
,
iconLight
:
'
closeall-editors.svg
'
},
ContextKeyExpr
.
and
(
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
ContextKeyExpr
.
not
(
'
groupActiveEditorDirty
'
)),
1000000
// towards the end
}
);
appendEditorToolItem
(
...
...
@@ -523,14 +531,39 @@ appendEditorToolItem(
title
:
nls
.
localize
(
'
close
'
,
"
Close
"
),
iconDark
:
'
close-dirty-inverse-alt.svg
'
,
iconLight
:
'
close-dirty-alt.svg
'
},
{
},
ContextKeyExpr
.
and
(
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
ContextKeyExpr
.
has
(
'
groupActiveEditorDirty
'
)),
1000000
,
// towards the far end
{
id
:
editorCommands
.
CLOSE_EDITORS_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeAll
'
,
"
Close All
"
),
iconDark
:
'
closeall-editors-inverse.svg
'
,
iconLight
:
'
closeall-editors.svg
'
}
);
// Diff Editor Title Menu: Previous Change
appendEditorToolItem
(
{
id
:
editorCommands
.
GOTO_PREVIOUS_CHANGE
,
title
:
nls
.
localize
(
'
navigate.prev.label
'
,
"
Previous Change
"
),
iconDark
:
'
previous-diff-inverse.svg
'
,
iconLight
:
'
previous-diff.svg
'
},
ContextKeyExpr
.
and
(
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
ContextKeyExpr
.
has
(
'
groupActiveEditorDirty
'
)),
1000000
// towards the end
TextCompareEditorActiveContext
,
10
);
// Diff Editor Title Menu: Next Change
appendEditorToolItem
(
{
id
:
editorCommands
.
GOTO_NEXT_CHANGE
,
title
:
nls
.
localize
(
'
navigate.next.label
'
,
"
Next Change
"
),
iconDark
:
'
next-diff-inverse.svg
'
,
iconLight
:
'
next-diff.svg
'
},
TextCompareEditorActiveContext
,
11
);
// Editor Commands for Command Palette
...
...
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
605b95d3
...
...
@@ -37,7 +37,10 @@ export const MOVE_ACTIVE_EDITOR_COMMAND_ID = 'moveActiveEditor';
export
const
LAYOUT_EDITOR_GROUPS_COMMAND_ID
=
'
layoutEditorGroups
'
;
export
const
KEEP_EDITOR_COMMAND_ID
=
'
workbench.action.keepEditor
'
;
export
const
SHOW_EDITORS_IN_GROUP
=
'
workbench.action.showEditorsInGroup
'
;
export
const
TOGGLE_DIFF_SIDE_BY_SIDE
=
'
toggle.diff.renderSideBySide
'
;
export
const
GOTO_NEXT_CHANGE
=
'
workbench.action.compareEditor.nextChange
'
;
export
const
GOTO_PREVIOUS_CHANGE
=
'
workbench.action.compareEditor.previousChange
'
;
export
const
SPLIT_EDITOR_UP
=
'
workbench.action.splitEditorUp
'
;
export
const
SPLIT_EDITOR_DOWN
=
'
workbench.action.splitEditorDown
'
;
...
...
@@ -224,7 +227,7 @@ export function mergeAllGroups(editorGroupService: IEditorGroupsService): void {
function
registerDiffEditorCommands
():
void
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.action.compareEditor.nextChange
'
,
id
:
GOTO_NEXT_CHANGE
,
weight
:
KeybindingWeight
.
WorkbenchContrib
,
when
:
TextCompareEditorVisibleContext
,
primary
:
KeyMod
.
Alt
|
KeyCode
.
F5
,
...
...
@@ -232,7 +235,7 @@ function registerDiffEditorCommands(): void {
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.action.compareEditor.previousChange
'
,
id
:
GOTO_PREVIOUS_CHANGE
,
weight
:
KeybindingWeight
.
WorkbenchContrib
,
when
:
TextCompareEditorVisibleContext
,
primary
:
KeyMod
.
Alt
|
KeyMod
.
Shift
|
KeyCode
.
F5
,
...
...
src/vs/workbench/browser/parts/editor/media/textdiffeditor.css
浏览文件 @
605b95d3
...
...
@@ -3,24 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.vs
.monaco-workbench
.textdiff-editor-action.next
{
background
:
url('next-diff.svg')
center
center
no-repeat
;
}
.vs
.monaco-workbench
.textdiff-editor-action.previous
{
background
:
url('previous-diff.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-workbench
.textdiff-editor-action.next
,
.hc-black
.monaco-workbench
.textdiff-editor-action.next
{
background
:
url('next-diff-inverse.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-workbench
.textdiff-editor-action.previous
,
.hc-black
.monaco-workbench
.textdiff-editor-action.previous
{
background
:
url('previous-diff-inverse.svg')
center
center
no-repeat
;
}
.vs
.monaco-workbench
.textdiff-editor-action.toggleIgnoreTrimWhitespace
{
opacity
:
1
;
background
:
url('paragraph.svg')
center
center
no-repeat
;
...
...
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
浏览文件 @
605b95d3
...
...
@@ -48,8 +48,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
private
diffNavigator
:
DiffNavigator
;
private
diffNavigatorDisposables
:
IDisposable
[]
=
[];
private
nextDiffAction
:
NavigateAction
;
private
previousDiffAction
:
NavigateAction
;
private
toggleIgnoreTrimWhitespaceAction
:
ToggleIgnoreTrimWhitespaceAction
;
constructor
(
...
...
@@ -88,8 +86,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
createEditorControl
(
parent
:
HTMLElement
,
configuration
:
ICodeEditorOptions
):
IDiffEditor
{
// Actions
this
.
nextDiffAction
=
new
NavigateAction
(
this
,
true
);
this
.
previousDiffAction
=
new
NavigateAction
(
this
,
false
);
this
.
toggleIgnoreTrimWhitespaceAction
=
new
ToggleIgnoreTrimWhitespaceAction
(
this
.
_actualConfigurationService
);
this
.
updateIgnoreTrimWhitespaceAction
();
...
...
@@ -141,11 +137,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
});
this
.
diffNavigatorDisposables
.
push
(
this
.
diffNavigator
);
this
.
diffNavigatorDisposables
.
push
(
this
.
diffNavigator
.
onDidUpdate
(()
=>
{
this
.
nextDiffAction
.
updateEnablement
();
this
.
previousDiffAction
.
updateEnablement
();
}));
// Enablement of actions
this
.
updateIgnoreTrimWhitespaceAction
();
...
...
@@ -294,9 +285,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
getActions
():
IAction
[]
{
return
[
this
.
toggleIgnoreTrimWhitespaceAction
,
this
.
previousDiffAction
,
this
.
nextDiffAction
this
.
toggleIgnoreTrimWhitespaceAction
];
}
...
...
@@ -384,39 +373,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
}
}
class
NavigateAction
extends
Action
{
static
ID_NEXT
=
'
workbench.action.compareEditor.nextChange
'
;
static
ID_PREV
=
'
workbench.action.compareEditor.previousChange
'
;
private
editor
:
TextDiffEditor
;
private
next
:
boolean
;
constructor
(
editor
:
TextDiffEditor
,
next
:
boolean
)
{
super
(
next
?
NavigateAction
.
ID_NEXT
:
NavigateAction
.
ID_PREV
);
this
.
editor
=
editor
;
this
.
next
=
next
;
this
.
label
=
this
.
next
?
nls
.
localize
(
'
navigate.next.label
'
,
"
Next Change
"
)
:
nls
.
localize
(
'
navigate.prev.label
'
,
"
Previous Change
"
);
this
.
class
=
this
.
next
?
'
textdiff-editor-action next
'
:
'
textdiff-editor-action previous
'
;
this
.
enabled
=
false
;
}
run
():
TPromise
<
any
>
{
if
(
this
.
next
)
{
this
.
editor
.
getDiffNavigator
().
next
();
}
else
{
this
.
editor
.
getDiffNavigator
().
previous
();
}
return
null
;
}
updateEnablement
():
void
{
this
.
enabled
=
this
.
editor
.
getDiffNavigator
().
canNavigate
();
}
}
class
ToggleIgnoreTrimWhitespaceAction
extends
Action
{
static
ID
=
'
workbench.action.compareEditor.toggleIgnoreTrimWhitespace
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录