Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
16466cb0
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
16466cb0
编写于
11月 19, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
context - rename saveable => readonly
上级
e3bb26ee
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
21 deletion
+21
-21
src/vs/workbench/browser/contextkeys.ts
src/vs/workbench/browser/contextkeys.ts
+5
-5
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+1
-1
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
+4
-4
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
.../workbench/contrib/files/browser/views/openEditorsView.ts
+5
-5
未找到文件。
src/vs/workbench/browser/contextkeys.ts
浏览文件 @
16466cb0
...
...
@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
import
{
IContextKeyService
,
IContextKey
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
InputFocusedContext
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
import
{
IWindowsConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
import
{
ActiveEditorContext
,
EditorsVisibleContext
,
TextCompareEditorVisibleContext
,
TextCompareEditorActiveContext
,
ActiveEditorGroupEmptyContext
,
MultipleEditorGroupsContext
,
TEXT_DIFF_EDITOR_ID
,
SplitEditorsVertically
,
InEditorZenModeContext
,
IsCenteredLayoutContext
,
ActiveEditorGroupIndexContext
,
ActiveEditorGroupLastContext
,
ActiveEditorIs
Saveable
Context
,
EditorAreaVisibleContext
,
DirtyWorkingCopiesContext
}
from
'
vs/workbench/common/editor
'
;
import
{
ActiveEditorContext
,
EditorsVisibleContext
,
TextCompareEditorVisibleContext
,
TextCompareEditorActiveContext
,
ActiveEditorGroupEmptyContext
,
MultipleEditorGroupsContext
,
TEXT_DIFF_EDITOR_ID
,
SplitEditorsVertically
,
InEditorZenModeContext
,
IsCenteredLayoutContext
,
ActiveEditorGroupIndexContext
,
ActiveEditorGroupLastContext
,
ActiveEditorIs
Readonly
Context
,
EditorAreaVisibleContext
,
DirtyWorkingCopiesContext
}
from
'
vs/workbench/common/editor
'
;
import
{
trackFocus
,
addDisposableListener
,
EventType
}
from
'
vs/base/browser/dom
'
;
import
{
preferredSideBySideGroupDirection
,
GroupDirection
,
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -53,7 +53,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
private
dirtyWorkingCopiesContext
:
IContextKey
<
boolean
>
;
private
activeEditorContext
:
IContextKey
<
string
|
null
>
;
private
activeEditorIs
Saveable
:
IContextKey
<
boolean
>
;
private
activeEditorIs
Readonly
:
IContextKey
<
boolean
>
;
private
activeEditorGroupEmpty
:
IContextKey
<
boolean
>
;
private
activeEditorGroupIndex
:
IContextKey
<
number
>
;
...
...
@@ -107,7 +107,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
// Editors
this
.
activeEditorContext
=
ActiveEditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
activeEditorIs
Saveable
=
ActiveEditorIsSaveable
Context
.
bindTo
(
this
.
contextKeyService
);
this
.
activeEditorIs
Readonly
=
ActiveEditorIsReadonly
Context
.
bindTo
(
this
.
contextKeyService
);
this
.
editorsVisibleContext
=
EditorsVisibleContext
.
bindTo
(
this
.
contextKeyService
);
this
.
textCompareEditorVisibleContext
=
TextCompareEditorVisibleContext
.
bindTo
(
this
.
contextKeyService
);
this
.
textCompareEditorActiveContext
=
TextCompareEditorActiveContext
.
bindTo
(
this
.
contextKeyService
);
...
...
@@ -222,10 +222,10 @@ export class WorkbenchContextKeysHandler extends Disposable {
if
(
activeControl
)
{
this
.
activeEditorContext
.
set
(
activeControl
.
getId
());
this
.
activeEditorIs
Saveable
.
set
(
!
activeControl
.
input
.
isReadonly
());
this
.
activeEditorIs
Readonly
.
set
(
activeControl
.
input
.
isReadonly
());
}
else
{
this
.
activeEditorContext
.
reset
();
this
.
activeEditorIs
Saveable
.
reset
();
this
.
activeEditorIs
Readonly
.
reset
();
}
}
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
16466cb0
...
...
@@ -26,7 +26,7 @@ import { isEqual } from 'vs/base/common/resources';
export
const
DirtyWorkingCopiesContext
=
new
RawContextKey
<
boolean
>
(
'
dirtyWorkingCopies
'
,
false
);
export
const
ActiveEditorContext
=
new
RawContextKey
<
string
|
null
>
(
'
activeEditor
'
,
null
);
export
const
ActiveEditorIs
SaveableContext
=
new
RawContextKey
<
boolean
>
(
'
activeEditorIsSaveable
'
,
false
);
export
const
ActiveEditorIs
ReadonlyContext
=
new
RawContextKey
<
boolean
>
(
'
activeEditorIsReadonly
'
,
false
);
export
const
EditorsVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
editorIsOpen
'
,
false
);
export
const
EditorPinnedContext
=
new
RawContextKey
<
boolean
>
(
'
editorPinned
'
,
false
);
export
const
EditorGroupActiveEditorDirtyContext
=
new
RawContextKey
<
boolean
>
(
'
groupActiveEditorDirty
'
,
false
);
...
...
src/vs/workbench/contrib/files/browser/fileActions.contribution.ts
浏览文件 @
16466cb0
...
...
@@ -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
,
Saveable
EditorContext
}
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
,
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
,
Readonly
EditorContext
}
from
'
vs/workbench/contrib/files/browser/fileCommands
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -26,7 +26,7 @@ import { Schemas } from 'vs/base/common/network';
import
{
WorkspaceFolderCountContext
,
IsWebContext
}
from
'
vs/workbench/browser/contextkeys
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
OpenFileFolderAction
,
OpenFileAction
,
OpenFolderAction
,
OpenWorkspaceAction
}
from
'
vs/workbench/browser/actions/workspaceActions
'
;
import
{
ActiveEditorIs
Saveable
Context
,
DirtyWorkingCopiesContext
,
ActiveEditorContext
}
from
'
vs/workbench/common/editor
'
;
import
{
ActiveEditorIs
Readonly
Context
,
DirtyWorkingCopiesContext
,
ActiveEditorContext
}
from
'
vs/workbench/common/editor
'
;
import
{
SidebarFocusContext
}
from
'
vs/workbench/common/viewlet
'
;
import
{
registerAndGetAmdImageURL
}
from
'
vs/base/common/amd
'
;
...
...
@@ -274,7 +274,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
// Not: editor groups
OpenEditorsGroupContext
.
toNegated
(),
// Not: readonly editors
SaveableEditorContext
,
ReadonlyEditorContext
.
toNegated
()
,
// Not: auto save after short delay
AutoSaveAfterShortDelayContext
.
toNegated
()
)
...
...
@@ -293,7 +293,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
// Not: editor groups
OpenEditorsGroupContext
.
toNegated
(),
// Not: readonly editors
SaveableEditorContext
,
ReadonlyEditorContext
.
toNegated
()
,
// Not: untitled editors (revert closes them)
ResourceContextKey
.
Scheme
.
notEqualsTo
(
Schemas
.
untitled
),
// Not: auto save after short delay
...
...
@@ -580,7 +580,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
command
:
{
id
:
SAVE_FILE_COMMAND_ID
,
title
:
nls
.
localize
({
key
:
'
miSave
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
&&Save
"
),
precondition
:
ContextKeyExpr
.
or
(
ActiveEditorIs
SaveableContext
,
ContextKeyExpr
.
and
(
ExplorerViewletVisibleContext
,
SidebarFocusContext
))
precondition
:
ContextKeyExpr
.
or
(
ActiveEditorIs
ReadonlyContext
.
toNegated
()
,
ContextKeyExpr
.
and
(
ExplorerViewletVisibleContext
,
SidebarFocusContext
))
},
order
:
1
});
...
...
@@ -659,7 +659,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
command
:
{
id
:
REVERT_FILE_COMMAND_ID
,
title
:
nls
.
localize
({
key
:
'
miRevert
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
Re&&vert File
"
),
precondition
:
ContextKeyExpr
.
or
(
ActiveEditorIs
SaveableContext
,
ContextKeyExpr
.
and
(
ExplorerViewletVisibleContext
,
SidebarFocusContext
))
precondition
:
ContextKeyExpr
.
or
(
ActiveEditorIs
ReadonlyContext
.
toNegated
()
,
ContextKeyExpr
.
and
(
ExplorerViewletVisibleContext
,
SidebarFocusContext
))
},
order
:
1
});
...
...
src/vs/workbench/contrib/files/browser/fileCommands.ts
浏览文件 @
16466cb0
...
...
@@ -67,7 +67,7 @@ export const SAVE_FILES_COMMAND_ID = 'workbench.action.files.saveFiles';
export
const
OpenEditorsGroupContext
=
new
RawContextKey
<
boolean
>
(
'
groupFocusedInOpenEditors
'
,
false
);
export
const
DirtyEditorContext
=
new
RawContextKey
<
boolean
>
(
'
dirtyEditor
'
,
false
);
export
const
SaveableEditorContext
=
new
RawContextKey
<
boolean
>
(
'
saveable
Editor
'
,
false
);
export
const
ReadonlyEditorContext
=
new
RawContextKey
<
boolean
>
(
'
readonly
Editor
'
,
false
);
export
const
ResourceSelectedForCompareContext
=
new
RawContextKey
<
boolean
>
(
'
resourceSelectedForCompare
'
,
false
);
export
const
REMOVE_ROOT_FOLDER_COMMAND_ID
=
'
removeRootFolder
'
;
...
...
@@ -318,16 +318,16 @@ function saveSelectedEditors(accessor: ServicesAccessor, options?: ISaveEditorsO
}
function
saveDirtyEditorsOfGroups
(
accessor
:
ServicesAccessor
,
groups
:
ReadonlyArray
<
IEditorGroup
>
,
options
?:
ISaveEditorsOptions
):
Promise
<
void
>
{
const
saveable
Editors
:
IEditorIdentifier
[]
=
[];
const
dirty
Editors
:
IEditorIdentifier
[]
=
[];
for
(
const
group
of
groups
)
{
for
(
const
editor
of
group
.
getEditors
(
EditorsOrder
.
MOST_RECENTLY_ACTIVE
))
{
if
(
editor
.
isDirty
())
{
saveable
Editors
.
push
({
groupId
:
group
.
id
,
editor
});
dirty
Editors
.
push
({
groupId
:
group
.
id
,
editor
});
}
}
}
return
doSaveEditors
(
accessor
,
saveable
Editors
,
options
);
return
doSaveEditors
(
accessor
,
dirty
Editors
,
options
);
}
async
function
doSaveEditors
(
accessor
:
ServicesAccessor
,
editors
:
IEditorIdentifier
[],
options
?:
ISaveEditorsOptions
):
Promise
<
void
>
{
...
...
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
浏览文件 @
16466cb0
...
...
@@ -30,7 +30,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
,
Saveable
EditorContext
}
from
'
vs/workbench/contrib/files/browser/fileCommands
'
;
import
{
DirtyEditorContext
,
OpenEditorsGroupContext
,
ReadonlyEditorContext
as
Readonly
EditorContext
}
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
{
ViewletPanel
,
IViewletPanelOptions
}
from
'
vs/workbench/browser/parts/views/panelViewlet
'
;
...
...
@@ -62,7 +62,7 @@ export class OpenEditorsView extends ViewletPanel {
private
resourceContext
!
:
ResourceContextKey
;
private
groupFocusedContext
!
:
IContextKey
<
boolean
>
;
private
dirtyEditorFocusedContext
!
:
IContextKey
<
boolean
>
;
private
saveable
EditorFocusedContext
!
:
IContextKey
<
boolean
>
;
private
readonly
EditorFocusedContext
!
:
IContextKey
<
boolean
>
;
constructor
(
options
:
IViewletViewOptions
,
...
...
@@ -236,19 +236,19 @@ export class OpenEditorsView extends ViewletPanel {
this
.
_register
(
this
.
resourceContext
);
this
.
groupFocusedContext
=
OpenEditorsGroupContext
.
bindTo
(
this
.
contextKeyService
);
this
.
dirtyEditorFocusedContext
=
DirtyEditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
saveableEditorFocusedContext
=
Saveable
EditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
readonlyEditorFocusedContext
=
Readonly
EditorContext
.
bindTo
(
this
.
contextKeyService
);
this
.
_register
(
this
.
list
.
onContextMenu
(
e
=>
this
.
onListContextMenu
(
e
)));
this
.
list
.
onFocusChange
(
e
=>
{
this
.
resourceContext
.
reset
();
this
.
groupFocusedContext
.
reset
();
this
.
dirtyEditorFocusedContext
.
reset
();
this
.
saveable
EditorFocusedContext
.
reset
();
this
.
readonly
EditorFocusedContext
.
reset
();
const
element
=
e
.
elements
.
length
?
e
.
elements
[
0
]
:
undefined
;
if
(
element
instanceof
OpenEditor
)
{
const
resource
=
element
.
getResource
();
this
.
dirtyEditorFocusedContext
.
set
(
element
.
editor
.
isDirty
());
this
.
saveableEditorFocusedContext
.
set
(
!
element
.
editor
.
isReadonly
());
this
.
readonlyEditorFocusedContext
.
set
(
element
.
editor
.
isReadonly
());
this
.
resourceContext
.
set
(
withUndefinedAsNull
(
resource
));
}
else
if
(
!!
element
)
{
this
.
groupFocusedContext
.
set
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录