Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
087c67ff
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,发现更多精彩内容 >>
提交
087c67ff
编写于
12月 21, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up context keys
上级
3756000c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
35 deletion
+42
-35
src/vs/platform/contextkey/common/contextkey.ts
src/vs/platform/contextkey/common/contextkey.ts
+4
-0
src/vs/workbench/common/resources.ts
src/vs/workbench/common/resources.ts
+13
-1
src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts
...arts/execution/electron-browser/execution.contribution.ts
+1
-2
src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts
.../parts/files/electron-browser/fileActions.contribution.ts
+14
-14
src/vs/workbench/parts/files/electron-browser/fileCommands.ts
...vs/workbench/parts/files/electron-browser/fileCommands.ts
+1
-4
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
...nch/parts/files/electron-browser/views/openEditorsView.ts
+9
-14
未找到文件。
src/vs/platform/contextkey/common/contextkey.ts
浏览文件 @
087c67ff
...
...
@@ -439,6 +439,10 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr {
public
isEqualTo
(
value
:
string
):
ContextKeyExpr
{
return
ContextKeyExpr
.
equals
(
this
.
key
,
value
);
}
public
notEqualsTo
(
value
:
string
):
ContextKeyExpr
{
return
ContextKeyExpr
.
notEquals
(
this
.
key
,
value
);
}
}
export
interface
IContext
{
...
...
src/vs/workbench/common/resources.ts
浏览文件 @
087c67ff
...
...
@@ -10,6 +10,7 @@ import paths = require('vs/base/common/paths');
import
{
basename
}
from
'
vs/base/common/paths
'
;
import
{
RawContextKey
,
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
export
class
ResourceContextKey
implements
IContextKey
<
URI
>
{
...
...
@@ -18,22 +19,29 @@ export class ResourceContextKey implements IContextKey<URI> {
static
LangId
=
new
RawContextKey
<
string
>
(
'
resourceLangId
'
,
undefined
);
static
Resource
=
new
RawContextKey
<
URI
>
(
'
resource
'
,
undefined
);
static
Extension
=
new
RawContextKey
<
string
>
(
'
resourceExtname
'
,
undefined
);
static
HasResource
=
new
RawContextKey
<
boolean
>
(
'
resourceSet
'
,
false
);
static
IsFile
=
new
RawContextKey
<
boolean
>
(
'
resourceIsFile
'
,
false
);
private
_resourceKey
:
IContextKey
<
URI
>
;
private
_schemeKey
:
IContextKey
<
string
>
;
private
_filenameKey
:
IContextKey
<
string
>
;
private
_langIdKey
:
IContextKey
<
string
>
;
private
_extensionKey
:
IContextKey
<
string
>
;
private
_hasResource
:
IContextKey
<
boolean
>
;
private
_isFile
:
IContextKey
<
boolean
>
;
constructor
(
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IModeService
private
_modeService
:
IModeService
@
IModeService
private
_modeService
:
IModeService
,
@
IFileService
private
_fileService
:
IFileService
)
{
this
.
_schemeKey
=
ResourceContextKey
.
Scheme
.
bindTo
(
contextKeyService
);
this
.
_filenameKey
=
ResourceContextKey
.
Filename
.
bindTo
(
contextKeyService
);
this
.
_langIdKey
=
ResourceContextKey
.
LangId
.
bindTo
(
contextKeyService
);
this
.
_resourceKey
=
ResourceContextKey
.
Resource
.
bindTo
(
contextKeyService
);
this
.
_extensionKey
=
ResourceContextKey
.
Extension
.
bindTo
(
contextKeyService
);
this
.
_hasResource
=
ResourceContextKey
.
HasResource
.
bindTo
(
contextKeyService
);
this
.
_isFile
=
ResourceContextKey
.
IsFile
.
bindTo
(
contextKeyService
);
}
set
(
value
:
URI
)
{
...
...
@@ -42,6 +50,8 @@ export class ResourceContextKey implements IContextKey<URI> {
this
.
_filenameKey
.
set
(
value
&&
basename
(
value
.
fsPath
));
this
.
_langIdKey
.
set
(
value
&&
this
.
_modeService
.
getModeIdByFilenameOrFirstLine
(
value
.
fsPath
));
this
.
_extensionKey
.
set
(
value
&&
paths
.
extname
(
value
.
fsPath
));
this
.
_hasResource
.
set
(
!!
value
);
this
.
_isFile
.
set
(
value
&&
this
.
_fileService
.
canHandleResource
(
value
));
}
reset
():
void
{
...
...
@@ -50,6 +60,8 @@ export class ResourceContextKey implements IContextKey<URI> {
this
.
_resourceKey
.
reset
();
this
.
_langIdKey
.
reset
();
this
.
_extensionKey
.
reset
();
this
.
_hasResource
.
reset
();
this
.
_isFile
.
reset
();
}
public
get
():
URI
{
...
...
src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts
浏览文件 @
087c67ff
...
...
@@ -25,7 +25,6 @@ import { DEFAULT_TERMINAL_WINDOWS, DEFAULT_TERMINAL_LINUX_READY, DEFAULT_TERMINA
import
{
WinTerminalService
,
MacTerminalService
,
LinuxTerminalService
}
from
'
vs/workbench/parts/execution/electron-browser/terminalService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
CommandsRegistry
,
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
EditorWithResourceFocusedInOpenEditorsContext
}
from
'
vs/workbench/parts/files/electron-browser/fileCommands
'
;
import
{
ResourceContextKey
}
from
'
vs/workbench/common/resources
'
;
if
(
env
.
isWindows
)
{
...
...
@@ -166,7 +165,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group
:
'
1_files
'
,
order
:
30
,
command
:
openConsoleCommand
,
when
:
EditorWithResourceFocusedInOpenEditorsContext
when
:
ResourceContextKey
.
Scheme
.
isEqualTo
(
'
file
'
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
ExplorerContext
,
{
...
...
src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts
浏览文件 @
087c67ff
...
...
@@ -11,7 +11,7 @@ import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTI
import
{
SyncActionDescriptor
,
MenuId
,
MenuRegistry
}
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
{
copyFocusedFilesExplorerViewItem
,
openWindowCommand
,
deleteFocusedFilesExplorerViewItemCommand
,
moveFocusedFilesExplorerViewItemToTrashCommand
,
renameFocusedFilesExplorerViewItemCommand
,
REVEAL_IN_OS_COMMAND_ID
,
COPY_PATH_COMMAND_ID
,
REVEAL_IN_EXPLORER_COMMAND_ID
,
OPEN_TO_SIDE_COMMAND_ID
,
EditorWithResourceFocusedInOpenEditorsContext
,
REVERT_FILE_COMMAND_ID
,
SAVE_FILE_COMMAND_ID
,
SAVE_FILE_LABEL
,
UntitledEditorFocusedInOpenEditorsContext
,
SAVE_FILE_AS_COMMAND_ID
,
SAVE_FILE_AS_LABEL
,
SAVE_ALL_IN_GROUP_COMMAND_ID
,
GroupFocusedInOpenEditorsContext
,
COMPARE_WITH_SAVED_COMMAND_ID
,
COMPARE_RESOURCE_COMMAND_ID
,
SELECT_FOR_COMPARE_COMMAND_ID
,
EditorFocusedInOpenEditorsContext
}
from
'
vs/workbench/parts/files/electron-browser/fileCommands
'
;
import
{
copyFocusedFilesExplorerViewItem
,
openWindowCommand
,
deleteFocusedFilesExplorerViewItemCommand
,
moveFocusedFilesExplorerViewItemToTrashCommand
,
renameFocusedFilesExplorerViewItemCommand
,
REVEAL_IN_OS_COMMAND_ID
,
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
}
from
'
vs/workbench/parts/files/electron-browser/fileCommands
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -145,7 +145,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group
:
'
1_files
'
,
order
:
10
,
command
:
openToSideCommand
,
when
:
EditorWithResourceFocusedInOpenEditorsContext
when
:
ResourceContextKey
.
HasResource
});
const
revealInOsCommand
=
{
...
...
@@ -156,7 +156,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group
:
'
1_files
'
,
order
:
20
,
command
:
revealInOsCommand
,
when
:
EditorWithResourceFocusedInOpenEditorsContext
when
:
ResourceContextKey
.
Scheme
.
isEqualTo
(
'
file
'
)
});
const
copyPathCommand
=
{
...
...
@@ -167,7 +167,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group
:
'
1_files
'
,
order
:
40
,
command
:
copyPathCommand
,
when
:
EditorWithResourceFocusedInOpenEditorsContext
when
:
ResourceContextKey
.
HasResource
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -177,7 +177,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
SAVE_FILE_COMMAND_ID
,
title
:
SAVE_FILE_LABEL
},
when
:
ContextKeyExpr
.
and
(
EditorWithResourceFocusedInOpenEditorsContext
,
AutoSaveNotAfterDelayContext
)
when
:
ContextKeyExpr
.
and
(
ResourceContextKey
.
IsFile
,
AutoSaveNotAfterDelayContext
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -187,7 +187,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
REVERT_FILE_COMMAND_ID
,
title
:
nls
.
localize
(
'
revert
'
,
"
Revert File
"
)
},
when
:
ContextKeyExpr
.
and
(
EditorWithResourceFocusedInOpenEditorsContext
,
AutoSaveNotAfterDelayContext
,
UntitledEditorFocusedInOpenEditorsContext
.
toNegated
()
)
when
:
ContextKeyExpr
.
and
(
ResourceContextKey
.
IsFile
,
AutoSaveNotAfterDelayContext
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -196,7 +196,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
SAVE_FILE_AS_COMMAND_ID
,
title
:
SAVE_FILE_AS_LABEL
},
when
:
ContextKeyExpr
.
and
(
EditorWithResourceFocusedInOpenEditorsContext
,
UntitledEditorFocusedInOpenEditorsContext
)
when
:
ResourceContextKey
.
Scheme
.
isEqualTo
(
'
untitled
'
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -205,7 +205,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
SAVE_ALL_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
saveAll
'
,
"
Save All
"
)
},
when
:
ContextKeyExpr
.
and
(
GroupFocusedInOpenEditors
Context
,
AutoSaveNotAfterDelayContext
)
when
:
ContextKeyExpr
.
and
(
OpenEditorsGroup
Context
,
AutoSaveNotAfterDelayContext
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -215,7 +215,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
COMPARE_WITH_SAVED_COMMAND_ID
,
title
:
nls
.
localize
(
'
compareWithSaved
'
,
"
Compare with Saved
"
)
},
when
:
ContextKeyExpr
.
and
(
EditorWithResourceFocusedInOpenEditorsContext
,
UntitledEditorFocusedInOpenEditorsContext
.
toNegated
())
when
:
ResourceContextKey
.
IsFile
});
const
compareResourceCommand
=
{
...
...
@@ -226,7 +226,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group
:
'
3_compare
'
,
order
:
20
,
command
:
compareResourceCommand
,
when
:
ContextKeyExpr
.
and
(
EditorWithResourceFocusedInOpenEditorsContext
,
)
when
:
ResourceContextKey
.
HasResource
});
const
selectForCompareCommand
=
{
...
...
@@ -237,7 +237,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group
:
'
3_compare
'
,
order
:
30
,
command
:
selectForCompareCommand
,
when
:
EditorWithResourceFocusedInOpenEditorsContext
when
:
ResourceContextKey
.
HasResource
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -247,7 +247,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
CLOSE_EDITOR_COMMAND_ID
,
title
:
nls
.
localize
(
'
close
'
,
"
Close
"
)
},
when
:
EditorFocusedInOpenEditorsContext
when
:
OpenEditorsGroupContext
.
toNegated
()
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -257,7 +257,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
id
:
CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeOthers
'
,
"
Close Others
"
)
},
when
:
EditorFocusedInOpenEditorsContext
when
:
OpenEditorsGroupContext
.
toNegated
()
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
OpenEditorsContext
,
{
...
...
@@ -311,7 +311,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group
:
'
1_files
'
,
order
:
20
,
command
:
revealInOsCommand
,
when
:
ResourceContextKey
.
Scheme
.
isEqualTo
(
'
file
'
)
when
:
ResourceContextKey
.
HasResource
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
ExplorerContext
,
{
...
...
src/vs/workbench/parts/files/electron-browser/fileCommands.ts
浏览文件 @
087c67ff
...
...
@@ -66,10 +66,7 @@ export const SAVE_ALL_IN_GROUP_COMMAND_ID = 'workbench.action.files.saveAllInGro
export
const
SAVE_FILES_COMMAND_ID
=
'
workbench.command.files.saveFiles
'
;
export
const
SAVE_FILES_LABEL
=
nls
.
localize
(
'
saveFiles
'
,
"
Save All Files
"
);
export
const
EditorFocusedInOpenEditorsContext
=
new
RawContextKey
<
boolean
>
(
'
editorFocusedInOpenEditors
'
,
false
);
export
const
EditorWithResourceFocusedInOpenEditorsContext
=
new
RawContextKey
<
boolean
>
(
'
editorWithResourceFocusedInOpenEditors
'
,
false
);
export
const
UntitledEditorFocusedInOpenEditorsContext
=
new
RawContextKey
<
boolean
>
(
'
untitledEditorFocusedInOpenEditors
'
,
false
);
export
const
GroupFocusedInOpenEditorsContext
=
new
RawContextKey
<
boolean
>
(
'
groupFocusedInOpenEditors
'
,
false
);
export
const
OpenEditorsGroupContext
=
new
RawContextKey
<
boolean
>
(
'
groupFocusedInOpenEditors
'
,
false
);
export
const
openWindowCommand
=
(
accessor
:
ServicesAccessor
,
paths
:
string
[],
forceNewWindow
:
boolean
)
=>
{
const
windowsService
=
accessor
.
get
(
IWindowsService
);
...
...
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
浏览文件 @
087c67ff
...
...
@@ -40,7 +40,8 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
fillInActions
}
from
'
vs/platform/actions/browser/menuItemActionItem
'
;
import
{
IMenuService
,
MenuId
,
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
import
{
EditorFocusedInOpenEditorsContext
,
UntitledEditorFocusedInOpenEditorsContext
,
GroupFocusedInOpenEditorsContext
,
EditorWithResourceFocusedInOpenEditorsContext
}
from
'
vs/workbench/parts/files/electron-browser/fileCommands
'
;
import
{
OpenEditorsGroupContext
}
from
'
vs/workbench/parts/files/electron-browser/fileCommands
'
;
import
{
ResourceContextKey
}
from
'
vs/workbench/common/resources
'
;
const
$
=
dom
.
$
;
...
...
@@ -58,9 +59,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
private
list
:
WorkbenchList
<
OpenEditor
|
IEditorGroup
>
;
private
contributedContextMenu
:
IMenu
;
private
needsRefresh
:
boolean
;
private
editorFocusedContext
:
IContextKey
<
boolean
>
;
private
editorWithResourceFocusedContext
:
IContextKey
<
boolean
>
;
private
untitledEditorFocusedContext
:
IContextKey
<
boolean
>
;
private
resourceContext
:
ResourceContextKey
;
private
groupFocusedContext
:
IContextKey
<
boolean
>
;
constructor
(
...
...
@@ -150,25 +149,21 @@ export class OpenEditorsView extends ViewsViewletPanel {
},
this
.
contextKeyService
,
this
.
listService
,
this
.
themeService
);
this
.
updateSize
();
// Bind context keys
OpenEditorsFocusedContext
.
bindTo
(
this
.
list
.
contextKeyService
);
ExplorerFocusedContext
.
bindTo
(
this
.
list
.
contextKeyService
);
this
.
editorFocusedContext
=
EditorFocusedInOpenEditorsContext
.
bindTo
(
this
.
contextKeyService
);
this
.
editorWithResourceFocusedContext
=
EditorWithResourceFocusedInOpenEditorsContext
.
bindTo
(
this
.
contextKeyService
);
this
.
untitledEditorFocusedContext
=
UntitledEditorFocusedInOpenEditorsContext
.
bindTo
(
this
.
contextKeyService
);
this
.
groupFocusedContext
=
GroupFocusedInOpenEditorsContext
.
bindTo
(
this
.
contextKeyService
);
this
.
resourceContext
=
this
.
instantiationService
.
createInstance
(
ResourceContextKey
);
this
.
groupFocusedContext
=
OpenEditorsGroupContext
.
bindTo
(
this
.
contextKeyService
);
this
.
disposables
.
push
(
this
.
list
.
onContextMenu
(
e
=>
this
.
onListContextMenu
(
e
)));
this
.
list
.
onFocusChange
(
e
=>
{
this
.
editorFocusedContext
.
reset
();
this
.
editorWithResourceFocusedContext
.
reset
();
this
.
resourceContext
.
reset
();
this
.
groupFocusedContext
.
reset
();
this
.
untitledEditorFocusedContext
.
reset
();
const
element
=
e
.
elements
.
length
?
e
.
elements
[
0
]
:
undefined
;
if
(
element
instanceof
OpenEditor
)
{
this
.
editorFocusedContext
.
set
(
true
);
this
.
editorWithResourceFocusedContext
.
set
(
!!
element
.
getResource
());
this
.
untitledEditorFocusedContext
.
set
(
element
.
isUntitled
());
this
.
resourceContext
.
set
(
element
.
getResource
());
}
else
if
(
!!
element
)
{
this
.
groupFocusedContext
.
set
(
true
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录