Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d1ab538d
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,发现更多精彩内容 >>
提交
d1ab538d
编写于
9月 08, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editor context keys - renames and deprecations
上级
5cca952f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
13 deletion
+27
-13
src/vs/workbench/browser/parts/editor/editorGroupView.ts
src/vs/workbench/browser/parts/editor/editorGroupView.ts
+10
-2
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+6
-0
src/vs/workbench/contrib/files/browser/fileActions.contribution.ts
...rkbench/contrib/files/browser/fileActions.contribution.ts
+6
-6
src/vs/workbench/contrib/files/browser/fileCommands.ts
src/vs/workbench/contrib/files/browser/fileCommands.ts
+2
-2
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
.../workbench/contrib/files/browser/views/openEditorsView.ts
+3
-3
未找到文件。
src/vs/workbench/browser/parts/editor/editorGroupView.ts
浏览文件 @
d1ab538d
...
...
@@ -5,7 +5,7 @@
import
'
vs/css!./media/editorgroupview
'
;
import
{
EditorGroup
,
IEditorOpenOptions
,
EditorCloseEvent
,
ISerializedEditorGroup
,
isSerializedEditorGroup
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
EditorInput
,
EditorOptions
,
GroupIdentifier
,
SideBySideEditorInput
,
CloseDirection
,
IEditorCloseEvent
,
EditorDirtyContext
,
IEditorPane
,
EditorGroupEditorsCountContext
,
SaveReason
,
IEditorPartOptionsChangeEvent
,
EditorsOrder
,
IVisibleEditorPane
,
EditorStickyContext
,
EditorPinnedContext
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
,
EditorOptions
,
GroupIdentifier
,
SideBySideEditorInput
,
CloseDirection
,
IEditorCloseEvent
,
EditorDirtyContext
,
IEditorPane
,
EditorGroupEditorsCountContext
,
SaveReason
,
IEditorPartOptionsChangeEvent
,
EditorsOrder
,
IVisibleEditorPane
,
EditorStickyContext
,
EditorPinnedContext
,
Deprecated_EditorPinnedContext
,
Deprecated_EditorDirtyContext
}
from
'
vs/workbench/common/editor
'
;
import
{
Event
,
Emitter
,
Relay
}
from
'
vs/base/common/event
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
addClass
,
addClasses
,
Dimension
,
trackFocus
,
toggleClass
,
removeClass
,
addDisposableListener
,
EventType
,
EventHelper
,
findParentWithClass
,
clearNode
,
isAncestor
}
from
'
vs/base/browser/dom
'
;
...
...
@@ -218,7 +218,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
private
handleGroupContextKeys
(
contextKeyService
:
IContextKeyService
):
void
{
const
groupActiveEditorDirtyContext
=
EditorDirtyContext
.
bindTo
(
contextKeyService
);
const
deprecatedGroupActiveEditorDirtyContext
=
Deprecated_EditorDirtyContext
.
bindTo
(
contextKeyService
);
const
groupActiveEditorPinnedContext
=
EditorPinnedContext
.
bindTo
(
contextKeyService
);
const
deprecatedGroupActiveEditorPinnedContext
=
Deprecated_EditorPinnedContext
.
bindTo
(
contextKeyService
);
const
groupActiveEditorStickyContext
=
EditorStickyContext
.
bindTo
(
contextKeyService
);
const
groupEditorsCountContext
=
EditorGroupEditorsCountContext
.
bindTo
(
contextKeyService
);
...
...
@@ -230,9 +232,14 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
const
activeEditor
=
this
.
_group
.
activeEditor
;
if
(
activeEditor
)
{
groupActiveEditorDirtyContext
.
set
(
activeEditor
.
isDirty
()
&&
!
activeEditor
.
isSaving
());
activeEditorListener
.
value
=
activeEditor
.
onDidChangeDirty
(()
=>
groupActiveEditorDirtyContext
.
set
(
activeEditor
.
isDirty
()
&&
!
activeEditor
.
isSaving
()));
deprecatedGroupActiveEditorDirtyContext
.
set
(
activeEditor
.
isDirty
()
&&
!
activeEditor
.
isSaving
());
activeEditorListener
.
value
=
activeEditor
.
onDidChangeDirty
(()
=>
{
groupActiveEditorDirtyContext
.
set
(
activeEditor
.
isDirty
()
&&
!
activeEditor
.
isSaving
());
deprecatedGroupActiveEditorDirtyContext
.
set
(
activeEditor
.
isDirty
()
&&
!
activeEditor
.
isSaving
());
});
}
else
{
groupActiveEditorDirtyContext
.
set
(
false
);
deprecatedGroupActiveEditorDirtyContext
.
set
(
false
);
}
};
...
...
@@ -247,6 +254,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
case
GroupChangeKind
.
EDITOR_PIN
:
if
(
e
.
editor
&&
e
.
editor
===
this
.
_group
.
activeEditor
)
{
groupActiveEditorPinnedContext
.
set
(
this
.
_group
.
isPinned
(
this
.
_group
.
activeEditor
));
deprecatedGroupActiveEditorPinnedContext
.
set
(
this
.
_group
.
isPinned
(
this
.
_group
.
activeEditor
));
}
break
;
case
GroupChangeKind
.
EDITOR_STICKY
:
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
d1ab538d
...
...
@@ -30,6 +30,12 @@ export const EditorPinnedContext = new RawContextKey<boolean>('activeEditorIsNot
export
const
EditorStickyContext
=
new
RawContextKey
<
boolean
>
(
'
activeEditorIsPinned
'
,
false
);
export
const
EditorReadonlyContext
=
new
RawContextKey
<
boolean
>
(
'
activeEditorIsReadonly
'
,
false
);
/** TODO@ben remove me eventually */
/** @deprecated */
export
const
Deprecated_EditorPinnedContext
=
new
RawContextKey
<
boolean
>
(
'
editorPinned
'
,
false
);
/** @deprecated */
export
const
Deprecated_EditorDirtyContext
=
new
RawContextKey
<
boolean
>
(
'
groupActiveEditorDirty
'
,
false
);
// Editor Kind Context Keys
export
const
ActiveEditorContext
=
new
RawContextKey
<
string
|
null
>
(
'
activeEditor
'
,
null
);
export
const
ActiveEditorAvailableEditorIdsContext
=
new
RawContextKey
<
string
>
(
'
activeEditorAvailableEditorIds
'
,
''
);
...
...
src/vs/workbench/contrib/files/browser/fileActions.contribution.ts
浏览文件 @
d1ab538d
...
...
@@ -10,7 +10,7 @@ import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTI
import
{
SyncActionDescriptor
,
MenuId
,
MenuRegistry
,
ILocalizedString
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actions
'
;
import
{
KeyMod
,
KeyChord
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
openWindowCommand
,
COPY_PATH_COMMAND_ID
,
REVEAL_IN_EXPLORER_COMMAND_ID
,
OPEN_TO_SIDE_COMMAND_ID
,
REVERT_FILE_COMMAND_ID
,
SAVE_FILE_COMMAND_ID
,
SAVE_FILE_LABEL
,
SAVE_FILE_AS_COMMAND_ID
,
SAVE_FILE_AS_LABEL
,
SAVE_ALL_IN_GROUP_COMMAND_ID
,
OpenEditorsGroupContext
,
COMPARE_WITH_SAVED_COMMAND_ID
,
COMPARE_RESOURCE_COMMAND_ID
,
SELECT_FOR_COMPARE_COMMAND_ID
,
ResourceSelectedForCompareContext
,
DirtyEditorContext
,
COMPARE_SELECTED_COMMAND_ID
,
REMOVE_ROOT_FOLDER_COMMAND_ID
,
REMOVE_ROOT_FOLDER_LABEL
,
SAVE_FILES_COMMAND_ID
,
COPY_RELATIVE_PATH_COMMAND_ID
,
SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID
,
SAVE_FILE_WITHOUT_FORMATTING_LABEL
,
newWindowCommand
,
ReadonlyEditorContext
,
OPEN_WITH_EXPLORER_COMMAND_ID
,
NEW_UNTITLED_FILE_COMMAND_ID
,
NEW_UNTITLED_FILE_LABEL
}
from
'
vs/workbench/contrib/files/browser/fileCommands
'
;
import
{
openWindowCommand
,
COPY_PATH_COMMAND_ID
,
REVEAL_IN_EXPLORER_COMMAND_ID
,
OPEN_TO_SIDE_COMMAND_ID
,
REVERT_FILE_COMMAND_ID
,
SAVE_FILE_COMMAND_ID
,
SAVE_FILE_LABEL
,
SAVE_FILE_AS_COMMAND_ID
,
SAVE_FILE_AS_LABEL
,
SAVE_ALL_IN_GROUP_COMMAND_ID
,
OpenEditorsGroupContext
,
COMPARE_WITH_SAVED_COMMAND_ID
,
COMPARE_RESOURCE_COMMAND_ID
,
SELECT_FOR_COMPARE_COMMAND_ID
,
ResourceSelectedForCompareContext
,
OpenEditorsDirtyEditorContext
,
COMPARE_SELECTED_COMMAND_ID
,
REMOVE_ROOT_FOLDER_COMMAND_ID
,
REMOVE_ROOT_FOLDER_LABEL
,
SAVE_FILES_COMMAND_ID
,
COPY_RELATIVE_PATH_COMMAND_ID
,
SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID
,
SAVE_FILE_WITHOUT_FORMATTING_LABEL
,
newWindowCommand
,
OpenEditors
ReadonlyEditorContext
,
OPEN_WITH_EXPLORER_COMMAND_ID
,
NEW_UNTITLED_FILE_COMMAND_ID
,
NEW_UNTITLED_FILE_LABEL
}
from
'
vs/workbench/contrib/files/browser/fileCommands
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ContextKeyExpr
,
ContextKeyExpression
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -259,7 +259,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
command
:
{
id
:
SAVE_FILE_COMMAND_ID
,
title
:
SAVE_FILE_LABEL
,
precondition
:
DirtyEditorContext
precondition
:
OpenEditors
DirtyEditorContext
},
when
:
ContextKeyExpr
.
or
(
// Untitled Editors
...
...
@@ -269,7 +269,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
// Not: editor groups
OpenEditorsGroupContext
.
toNegated
(),
// Not: readonly editors
ReadonlyEditorContext
.
toNegated
(),
OpenEditors
ReadonlyEditorContext
.
toNegated
(),
// Not: auto save after short delay
AutoSaveAfterShortDelayContext
.
toNegated
()
)
...
...
@@ -282,13 +282,13 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
command
:
{
id
:
REVERT_FILE_COMMAND_ID
,
title
:
nls
.
localize
(
'
revert
'
,
"
Revert File
"
),
precondition
:
DirtyEditorContext
precondition
:
OpenEditors
DirtyEditorContext
},
when
:
ContextKeyExpr
.
and
(
// Not: editor groups
OpenEditorsGroupContext
.
toNegated
(),
// Not: readonly editors
ReadonlyEditorContext
.
toNegated
(),
OpenEditors
ReadonlyEditorContext
.
toNegated
(),
// Not: untitled editors (revert closes them)
ResourceContextKey
.
Scheme
.
notEqualsTo
(
Schemas
.
untitled
),
// Not: auto save after short delay
...
...
@@ -314,7 +314,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
command
:
{
id
:
COMPARE_WITH_SAVED_COMMAND_ID
,
title
:
nls
.
localize
(
'
compareWithSaved
'
,
"
Compare with Saved
"
),
precondition
:
DirtyEditorContext
precondition
:
OpenEditors
DirtyEditorContext
},
when
:
ContextKeyExpr
.
and
(
ResourceContextKey
.
IsFileSystemResource
,
AutoSaveAfterShortDelayContext
.
toNegated
(),
WorkbenchListDoubleSelection
.
toNegated
())
});
...
...
src/vs/workbench/contrib/files/browser/fileCommands.ts
浏览文件 @
d1ab538d
...
...
@@ -74,8 +74,8 @@ export const SAVE_ALL_IN_GROUP_COMMAND_ID = 'workbench.files.action.saveAllInGro
export
const
SAVE_FILES_COMMAND_ID
=
'
workbench.action.files.saveFiles
'
;
export
const
OpenEditorsGroupContext
=
new
RawContextKey
<
boolean
>
(
'
groupFocusedInOpenEditors
'
,
false
);
export
const
DirtyEditorContext
=
new
RawContextKey
<
boolean
>
(
'
dirtyEditorFocusedInOpenEditors
'
,
false
);
export
const
ReadonlyEditorContext
=
new
RawContextKey
<
boolean
>
(
'
readonlyEditorFocusedInOpenEditors
'
,
false
);
export
const
OpenEditors
DirtyEditorContext
=
new
RawContextKey
<
boolean
>
(
'
dirtyEditorFocusedInOpenEditors
'
,
false
);
export
const
OpenEditors
ReadonlyEditorContext
=
new
RawContextKey
<
boolean
>
(
'
readonlyEditorFocusedInOpenEditors
'
,
false
);
export
const
ResourceSelectedForCompareContext
=
new
RawContextKey
<
boolean
>
(
'
resourceSelectedForCompare
'
,
false
);
export
const
REMOVE_ROOT_FOLDER_COMMAND_ID
=
'
removeRootFolder
'
;
...
...
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
浏览文件 @
d1ab538d
...
...
@@ -31,7 +31,7 @@ import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
createAndFillInContextMenuActions
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IMenuService
,
MenuId
,
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
import
{
DirtyEditorContext
,
OpenEditorsGroupContext
,
ReadonlyEditorContext
}
from
'
vs/workbench/contrib/files/browser/fileCommands
'
;
import
{
OpenEditorsDirtyEditorContext
,
OpenEditorsGroupContext
,
OpenEditors
ReadonlyEditorContext
}
from
'
vs/workbench/contrib/files/browser/fileCommands
'
;
import
{
ResourceContextKey
}
from
'
vs/workbench/common/resources
'
;
import
{
ResourcesDropHandler
,
fillResourceDataTransfers
,
CodeDataTransfers
,
containsDragType
}
from
'
vs/workbench/browser/dnd
'
;
import
{
ViewPane
}
from
'
vs/workbench/browser/parts/views/viewPaneContainer
'
;
...
...
@@ -243,8 +243,8 @@ export class OpenEditorsView extends ViewPane {
this
.
resourceContext
=
this
.
instantiationService
.
createInstance
(
ResourceContextKey
);
this
.
_register
(
this
.
resourceContext
);
this
.
groupFocusedContext
=
OpenEditorsGroupContext
.
bindTo
(
this
.
contextKeyService
);
this
.
dirtyEditorFocusedContext
=
DirtyEditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
readonlyEditorFocusedContext
=
ReadonlyEditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
dirtyEditorFocusedContext
=
OpenEditors
DirtyEditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
readonlyEditorFocusedContext
=
OpenEditors
ReadonlyEditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
_register
(
this
.
list
.
onContextMenu
(
e
=>
this
.
onListContextMenu
(
e
)));
this
.
list
.
onDidChangeFocus
(
e
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录