Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
01373f73
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,发现更多精彩内容 >>
提交
01373f73
编写于
2月 02, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
copy path command in explorer (for #4557)
上级
10dc7423
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
80 addition
and
39 deletion
+80
-39
src/vs/workbench/parts/files/browser/fileActions.contribution.ts
...workbench/parts/files/browser/fileActions.contribution.ts
+20
-11
src/vs/workbench/parts/files/browser/fileCommands.ts
src/vs/workbench/parts/files/browser/fileCommands.ts
+26
-17
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+16
-5
src/vs/workbench/parts/files/browser/views/openEditorsView.ts
...vs/workbench/parts/files/browser/views/openEditorsView.ts
+16
-5
src/vs/workbench/parts/files/common/files.ts
src/vs/workbench/parts/files/common/files.ts
+2
-1
未找到文件。
src/vs/workbench/parts/files/browser/fileActions.contribution.ts
浏览文件 @
01373f73
...
...
@@ -23,7 +23,7 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
OpenFolderAction
,
OpenFileFolderAction
}
from
'
vs/workbench/browser/actions/fileActions
'
;
import
{
copyPath
Command
,
revealInExplorerCommand
,
revealInOSCommand
,
openFolderPickerCommand
,
openWindowCommand
,
openFileInNewWindowCommand
,
openFocussedExplorerItemCommand
,
deleteFocussedExplorerItemCommand
,
moveFocussedExplorerItemToTrashCommand
,
openFocussedExplorerSideBySideItemCommand
,
renameFocussedExplorer
ItemCommand
}
from
'
vs/workbench/parts/files/browser/fileCommands
'
;
import
{
copyPath
OfFocussedExplorerItem
,
copyPathCommand
,
revealInExplorerCommand
,
revealInOSCommand
,
openFolderPickerCommand
,
openWindowCommand
,
openFileInNewWindowCommand
,
openFocussedExplorerViewItemCommand
,
deleteFocussedExplorerViewItemCommand
,
moveFocussedExplorerViewItemToTrashCommand
,
openFocussedExplorerViewItemSideBySideCommand
,
renameFocussedExplorerView
ItemCommand
}
from
'
vs/workbench/parts/files/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
'
;
...
...
@@ -239,61 +239,70 @@ CommandsRegistry.registerCommand('_files.openFolderPicker', openFolderPickerComm
CommandsRegistry
.
registerCommand
(
'
_files.windowOpen
'
,
openWindowCommand
);
CommandsRegistry
.
registerCommand
(
'
workbench.action.files.openFileInNewWindow
'
,
openFileInNewWindowCommand
);
const
filesExplorerFocusCondition
=
ContextKeyExpr
.
and
(
ContextKeyExpr
.
has
(
'
explorerViewletVisible
'
),
ContextKeyExpr
.
has
(
'
filesExplorerFocus
'
));
const
explorerFocusCondition
=
ContextKeyExpr
.
and
(
ContextKeyExpr
.
has
(
'
explorerViewletVisible
'
),
ContextKeyExpr
.
has
(
'
explorerFocus
'
));
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.files.action.open
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
e
xplorerFocusCondition
,
when
:
filesE
xplorerFocusCondition
,
primary
:
KeyCode
.
Enter
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
DownArrow
},
handler
:
openFocussedExplorerItemCommand
handler
:
openFocussedExplorer
View
ItemCommand
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.files.action.openToSide
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
e
xplorerFocusCondition
,
when
:
filesE
xplorerFocusCondition
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Enter
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
Enter
},
handler
:
openFocussedExplorer
SideBySideItem
Command
handler
:
openFocussedExplorer
ViewItemSideBySide
Command
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.files.action.triggerRename
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
e
xplorerFocusCondition
,
when
:
filesE
xplorerFocusCondition
,
primary
:
KeyCode
.
F2
,
mac
:
{
primary
:
KeyCode
.
Enter
},
handler
:
renameFocussedExplorerItemCommand
handler
:
renameFocussedExplorer
View
ItemCommand
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.files.action.moveFileToTrash
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
e
xplorerFocusCondition
,
when
:
filesE
xplorerFocusCondition
,
primary
:
KeyCode
.
Delete
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Backspace
},
handler
:
moveFocussedExplorerItemToTrashCommand
handler
:
moveFocussedExplorer
View
ItemToTrashCommand
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.files.action.delete
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
e
xplorerFocusCondition
,
when
:
filesE
xplorerFocusCondition
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
Delete
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Alt
|
KeyCode
.
Backspace
},
handler
:
deleteFocussedExplorerItemCommand
handler
:
deleteFocussedExplorerViewItemCommand
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.action.files.copyPath
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
explorerFocusCondition
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Alt
|
KeyCode
.
KEY_C
,
handler
:
copyPathOfFocussedExplorerItem
});
// Editor Title Context Menu
...
...
src/vs/workbench/parts/files/browser/fileCommands.ts
浏览文件 @
01373f73
...
...
@@ -75,10 +75,7 @@ export const revealInExplorerCommand = (accessor: ServicesAccessor, resource: UR
});
};
export
const
openFocussedExplorerItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
openFocussedExplorerItem
(
accessor
,
false
);
export
const
openFocussedExplorerSideBySideItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
openFocussedExplorerItem
(
accessor
,
true
);
function
openFocussedExplorerItem
(
accessor
:
ServicesAccessor
,
sideBySide
:
boolean
):
void
{
function
openFocussedExplorerViewItem
(
accessor
:
ServicesAccessor
,
sideBySide
:
boolean
):
void
{
withFocussedExplorerViewItem
(
accessor
).
then
(
res
=>
{
if
(
res
)
{
...
...
@@ -106,18 +103,6 @@ function runActionOnFocussedExplorerViewItem(accessor: ServicesAccessor, id: str
});
}
export
const
renameFocussedExplorerItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
runActionOnFocussedExplorerViewItem
(
accessor
,
'
workbench.files.action.triggerRename
'
);
};
export
const
deleteFocussedExplorerItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
runActionOnFocussedExplorerViewItem
(
accessor
,
'
workbench.files.action.moveFileToTrash
'
,
{
useTrash
:
false
});
};
export
const
moveFocussedExplorerItemToTrashCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
runActionOnFocussedExplorerViewItem
(
accessor
,
'
workbench.files.action.moveFileToTrash
'
,
{
useTrash
:
true
});
};
function
withExplorer
(
accessor
:
ServicesAccessor
):
TPromise
<
ExplorerViewlet
>
{
const
viewletService
=
accessor
.
get
(
IViewletService
);
...
...
@@ -146,7 +131,7 @@ function withFocussedExplorerViewItem(accessor: ServicesAccessor): TPromise<{ ex
});
};
export
function
withFocussedExplorer
Resource
(
accessor
:
ServicesAccessor
):
TPromise
<
IFileResource
>
{
function
withFocussedExplorerFile
Resource
(
accessor
:
ServicesAccessor
):
TPromise
<
IFileResource
>
{
return
withExplorer
(
accessor
).
then
(
explorer
=>
{
if
(
!
explorer
)
{
return
void
0
;
// hidden explorer
...
...
@@ -169,4 +154,28 @@ export function withFocussedExplorerResource(accessor: ServicesAccessor): TPromi
return
explorerItemToFileResource
(
focussedTree
.
getFocus
());
});
};
export
const
openFocussedExplorerViewItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
openFocussedExplorerViewItem
(
accessor
,
false
);
export
const
openFocussedExplorerViewItemSideBySideCommand
=
(
accessor
:
ServicesAccessor
)
=>
openFocussedExplorerViewItem
(
accessor
,
true
);
export
const
renameFocussedExplorerViewItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
runActionOnFocussedExplorerViewItem
(
accessor
,
'
workbench.files.action.triggerRename
'
);
};
export
const
deleteFocussedExplorerViewItemCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
runActionOnFocussedExplorerViewItem
(
accessor
,
'
workbench.files.action.moveFileToTrash
'
,
{
useTrash
:
false
});
};
export
const
moveFocussedExplorerViewItemToTrashCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
runActionOnFocussedExplorerViewItem
(
accessor
,
'
workbench.files.action.moveFileToTrash
'
,
{
useTrash
:
true
});
};
export
const
copyPathOfFocussedExplorerItem
=
(
accessor
:
ServicesAccessor
)
=>
{
withFocussedExplorerFileResource
(
accessor
).
then
(
file
=>
{
if
(
file
)
{
copyPathCommand
(
accessor
,
file
.
resource
);
}
});
};
\ No newline at end of file
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
01373f73
...
...
@@ -16,7 +16,7 @@ import { Action, IActionRunner, IAction } from 'vs/base/common/actions';
import
{
prepareActions
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
IFilesConfiguration
,
ExplorerFolderContext
,
ExplorerFocussedContext
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFilesConfiguration
,
ExplorerFolderContext
,
FilesExplorerFocussedContext
,
ExplorerFocussedContext
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
FileOperation
,
FileOperationEvent
,
IResolveFileOptions
,
FileChangeType
,
FileChangesEvent
,
IFileChange
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
RefreshViewExplorerAction
,
NewFolderAction
,
NewFileAction
}
from
'
vs/workbench/parts/files/browser/fileActions
'
;
import
{
FileDragAndDrop
,
FileFilter
,
FileSorter
,
FileController
,
FileRenderer
,
FileDataSource
,
FileViewletState
,
FileAccessibilityProvider
}
from
'
vs/workbench/parts/files/browser/views/explorerViewer
'
;
...
...
@@ -60,6 +60,7 @@ export class ExplorerView extends CollapsibleViewletView {
private
resourceContext
:
ResourceContextKey
;
private
folderContext
:
IContextKey
<
boolean
>
;
private
filesExplorerFocussedContext
:
IContextKey
<
boolean
>
;
private
explorerFocussedContext
:
IContextKey
<
boolean
>
;
private
shouldRefresh
:
boolean
;
...
...
@@ -99,6 +100,8 @@ export class ExplorerView extends CollapsibleViewletView {
this
.
resourceContext
=
instantiationService
.
createInstance
(
ResourceContextKey
);
this
.
folderContext
=
ExplorerFolderContext
.
bindTo
(
contextKeyService
);
this
.
filesExplorerFocussedContext
=
FilesExplorerFocussedContext
.
bindTo
(
contextKeyService
);
this
.
explorerFocussedContext
=
ExplorerFocussedContext
.
bindTo
(
contextKeyService
);
}
...
...
@@ -360,10 +363,18 @@ export class ExplorerView extends CollapsibleViewletView {
}));
// Update explorer focus context
const
explorerFocusTracker
=
DOM
.
trackFocus
(
this
.
explorerViewer
.
getHTMLElement
());
explorerFocusTracker
.
addFocusListener
(()
=>
this
.
explorerFocussedContext
.
set
(
true
));
explorerFocusTracker
.
addBlurListener
(()
=>
this
.
explorerFocussedContext
.
reset
());
this
.
toDispose
.
push
(
explorerFocusTracker
);
const
viewerFocusTracker
=
DOM
.
trackFocus
(
this
.
explorerViewer
.
getHTMLElement
());
viewerFocusTracker
.
addFocusListener
(()
=>
{
setTimeout
(()
=>
{
this
.
filesExplorerFocussedContext
.
set
(
true
);
this
.
explorerFocussedContext
.
set
(
true
);
},
0
/* wait for any BLUR to happen */
);
});
viewerFocusTracker
.
addBlurListener
(()
=>
{
this
.
filesExplorerFocussedContext
.
reset
();
this
.
explorerFocussedContext
.
reset
();
});
this
.
toDispose
.
push
(
viewerFocusTracker
);
return
this
.
explorerViewer
;
}
...
...
src/vs/workbench/parts/files/browser/views/openEditorsView.ts
浏览文件 @
01373f73
...
...
@@ -19,7 +19,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
IEditorStacksModel
,
IStacksModelChangeEvent
,
IEditorGroup
}
from
'
vs/workbench/common/editor
'
;
import
{
SaveAllAction
}
from
'
vs/workbench/parts/files/browser/fileActions
'
;
import
{
AdaptiveCollapsibleViewletView
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
IFilesConfiguration
,
VIEWLET_ID
,
OpenEditorsFocussedContext
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFilesConfiguration
,
VIEWLET_ID
,
OpenEditorsFocussedContext
,
ExplorerFocussedContext
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
ITextFileService
,
AutoSaveMode
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
OpenEditor
}
from
'
vs/workbench/parts/files/common/explorerViewModel
'
;
...
...
@@ -49,6 +49,7 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
private
fullRefreshNeeded
:
boolean
;
private
openEditorsFocussedContext
:
IContextKey
<
boolean
>
;
private
explorerFocussedContext
:
IContextKey
<
boolean
>
;
constructor
(
actionRunner
:
IActionRunner
,
settings
:
any
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
...
...
@@ -65,7 +66,9 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
this
.
settings
=
settings
;
this
.
model
=
editorGroupService
.
getStacksModel
();
this
.
openEditorsFocussedContext
=
OpenEditorsFocussedContext
.
bindTo
(
contextKeyService
);
this
.
explorerFocussedContext
=
ExplorerFocussedContext
.
bindTo
(
contextKeyService
);
this
.
structuralRefreshDelay
=
0
;
this
.
structuralTreeRefreshScheduler
=
new
RunOnceScheduler
(()
=>
this
.
structuralTreeUpdate
(),
this
.
structuralRefreshDelay
);
...
...
@@ -116,10 +119,18 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
});
// Update open editors focus context
const
explorerFocusTracker
=
dom
.
trackFocus
(
this
.
tree
.
getHTMLElement
());
explorerFocusTracker
.
addFocusListener
(()
=>
this
.
openEditorsFocussedContext
.
set
(
true
));
explorerFocusTracker
.
addBlurListener
(()
=>
this
.
openEditorsFocussedContext
.
reset
());
this
.
toDispose
.
push
(
explorerFocusTracker
);
const
viewerFocusTracker
=
dom
.
trackFocus
(
this
.
tree
.
getHTMLElement
());
viewerFocusTracker
.
addFocusListener
(()
=>
{
setTimeout
(()
=>
{
this
.
openEditorsFocussedContext
.
set
(
true
);
this
.
explorerFocussedContext
.
set
(
true
);
},
0
/* wait for any BLUR to happen */
);
});
viewerFocusTracker
.
addBlurListener
(()
=>
{
this
.
openEditorsFocussedContext
.
reset
();
this
.
explorerFocussedContext
.
reset
();
});
this
.
toDispose
.
push
(
viewerFocusTracker
);
this
.
fullRefreshNeeded
=
true
;
this
.
structuralTreeUpdate
();
...
...
src/vs/workbench/parts/files/common/files.ts
浏览文件 @
01373f73
...
...
@@ -21,8 +21,9 @@ export const VIEWLET_ID = 'workbench.view.explorer';
*/
export
const
ExplorerViewletVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
explorerViewletVisible
'
,
true
);
export
const
ExplorerFolderContext
=
new
RawContextKey
<
boolean
>
(
'
explorerResourceIsFolder
'
,
false
);
export
const
ExplorerFocussedContext
=
new
RawContextKey
<
boolean
>
(
'
e
xplorerFocus
'
,
false
);
export
const
FilesExplorerFocussedContext
=
new
RawContextKey
<
boolean
>
(
'
filesE
xplorerFocus
'
,
false
);
export
const
OpenEditorsFocussedContext
=
new
RawContextKey
<
boolean
>
(
'
openEditorsFocus
'
,
false
);
export
const
ExplorerFocussedContext
=
new
RawContextKey
<
boolean
>
(
'
explorerFocus
'
,
false
);
/**
* File editor input id.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录