Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f3a9380c
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,发现更多精彩内容 >>
提交
f3a9380c
编写于
1月 18, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reduce hacks in getMultiSelectedEditorContexts
上级
2404eeaf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
27 deletion
+27
-27
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+6
-6
src/vs/workbench/parts/files/common/explorerModel.ts
src/vs/workbench/parts/files/common/explorerModel.ts
+7
-7
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
...nch/parts/files/electron-browser/views/openEditorsView.ts
+14
-14
未找到文件。
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
f3a9380c
...
...
@@ -13,7 +13,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
import
{
IEditor
,
Position
,
POSITIONS
,
Direction
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
TextDiffEditor
}
from
'
vs/workbench/browser/parts/editor/textDiffEditor
'
;
import
{
EditorStacksModel
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
EditorStacksModel
,
EditorGroup
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
KeyMod
,
KeyCode
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
...
@@ -496,21 +496,21 @@ function positionAndInput(editorGroupService: IEditorGroupService, editorService
}
export
function
getMultiSelectedEditorContexts
(
editorContext
:
IEditorIdentifier
,
listService
:
IListService
):
IEditorIdentifier
[]
{
// TODO@Isidor this method is not nice since it assumes it is working on open editors view and maps elements on top of that
const
list
=
listService
.
lastFocusedList
;
// Mapping for open editors view
const
elementToContext
=
element
=>
element
&&
element
.
editorGroup
&&
element
.
editorInput
?
{
group
:
element
.
editorGroup
,
editor
:
element
.
editorInput
}
:
{
group
:
element
,
editor
:
undefined
};
const
isEditorIdentifier
=
(
element
:
any
)
=>
'
group
'
in
element
&&
'
editor
'
in
element
;
const
elementToContext
=
(
element
:
IEditorIdentifier
|
EditorGroup
)
=>
element
instanceof
EditorGroup
?
{
group
:
element
,
editor
:
undefined
}
:
element
;
if
(
list
instanceof
List
&&
list
.
isDOMFocused
())
{
const
selection
=
list
.
getSelectedElements
();
const
focus
=
list
.
getFocusedElements
();
// Only respect selection if it contains focused element
if
(
focus
.
length
&&
selection
&&
selection
.
indexOf
(
focus
[
0
])
>=
0
)
{
return
list
.
getSelectedElements
().
map
(
elementToContext
);
return
list
.
getSelectedElements
().
filter
(
e
=>
e
instanceof
EditorGroup
||
isEditorIdentifier
(
e
)).
map
(
elementToContext
);
}
if
(
focus
)
{
return
focus
.
map
(
elementToContext
);
if
(
focus
.
length
)
{
return
focus
.
filter
(
e
=>
e
instanceof
EditorGroup
||
isEditorIdentifier
(
e
)).
map
(
elementToContext
);
}
}
...
...
src/vs/workbench/parts/files/common/explorerModel.ts
浏览文件 @
f3a9380c
...
...
@@ -12,7 +12,7 @@ import { isLinux } from 'vs/base/common/platform';
import
{
IFileStat
,
isParent
}
from
'
vs/platform/files/common/files
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IEditorGroup
,
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorGroup
,
toResource
,
IEditorIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
getPathLabel
}
from
'
vs/base/common/labels
'
;
...
...
@@ -369,18 +369,18 @@ export class NewStatPlaceholder extends FileStat {
}
}
export
class
OpenEditor
{
export
class
OpenEditor
implements
IEditorIdentifier
{
constructor
(
private
editor
:
IEditorInput
,
private
group
:
IEditorGroup
)
{
constructor
(
private
_editor
:
IEditorInput
,
private
_
group
:
IEditorGroup
)
{
// noop
}
public
get
editor
Input
()
{
return
this
.
editor
;
public
get
editor
()
{
return
this
.
_
editor
;
}
public
get
editorG
roup
()
{
return
this
.
group
;
public
get
g
roup
()
{
return
this
.
_
group
;
}
public
getId
():
string
{
...
...
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
浏览文件 @
f3a9380c
...
...
@@ -276,8 +276,8 @@ export class OpenEditorsView extends ViewsViewletPanel {
}
if
(
event
.
browserEvent
&&
event
.
browserEvent
.
button
===
1
/* Middle Button */
)
{
const
position
=
this
.
model
.
positionOfGroup
(
element
.
editorG
roup
);
this
.
editorService
.
closeEditor
(
position
,
element
.
editor
Input
).
done
(
null
,
errors
.
onUnexpectedError
);
const
position
=
this
.
model
.
positionOfGroup
(
element
.
g
roup
);
this
.
editorService
.
closeEditor
(
position
,
element
.
editor
).
done
(
null
,
errors
.
onUnexpectedError
);
}
else
{
this
.
openEditor
(
element
,
{
preserveFocus
:
!
isDoubleClick
,
pinned
:
isDoubleClick
,
sideBySide
:
event
.
browserEvent
.
altKey
});
}
...
...
@@ -292,12 +292,12 @@ export class OpenEditorsView extends ViewsViewletPanel {
}
*/
this
.
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
'
workbench.files.openFile
'
,
from
:
'
openEditors
'
});
let
position
=
this
.
model
.
positionOfGroup
(
element
.
editorG
roup
);
let
position
=
this
.
model
.
positionOfGroup
(
element
.
g
roup
);
if
(
options
.
sideBySide
&&
position
!==
Position
.
THREE
)
{
position
++
;
}
this
.
editorGroupService
.
activateGroup
(
this
.
model
.
groupAt
(
position
));
this
.
editorService
.
openEditor
(
element
.
editor
Input
,
options
,
position
)
this
.
editorService
.
openEditor
(
element
.
editor
,
options
,
position
)
.
done
(()
=>
this
.
editorGroupService
.
activateGroup
(
this
.
model
.
groupAt
(
position
)),
errors
.
onUnexpectedError
);
}
}
...
...
@@ -308,10 +308,10 @@ export class OpenEditorsView extends ViewsViewletPanel {
getAnchor
:
()
=>
e
.
anchor
,
getActions
:
()
=>
{
const
actions
=
[];
fillInActions
(
this
.
contributedContextMenu
,
{
shouldForwardArgs
:
true
,
arg
:
element
instanceof
OpenEditor
?
element
.
editor
Input
.
getResource
()
:
{}
},
actions
,
this
.
contextMenuService
);
fillInActions
(
this
.
contributedContextMenu
,
{
shouldForwardArgs
:
true
,
arg
:
element
instanceof
OpenEditor
?
element
.
editor
.
getResource
()
:
{}
},
actions
,
this
.
contextMenuService
);
return
TPromise
.
as
(
actions
);
},
getActionsContext
:
()
=>
element
instanceof
OpenEditor
?
{
group
:
element
.
editorGroup
,
editor
:
element
.
editorInput
}
:
{
group
:
element
}
getActionsContext
:
()
=>
element
instanceof
OpenEditor
?
{
group
:
element
.
group
,
editor
:
element
.
editor
}
:
{
group
:
element
}
});
}
...
...
@@ -482,7 +482,7 @@ class EditorGroupRenderer implements IRenderer<IEditorGroup, IEditorGroupTemplat
const
model
=
this
.
editorGroupService
.
getStacksModel
();
const
positionOfTargetGroup
=
model
.
positionOfGroup
(
editorGroupTemplate
.
editorGroup
);
OpenEditorRenderer
.
DRAGGED_OPEN_EDITORS
.
forEach
(
oe
=>
this
.
editorGroupService
.
moveEditor
(
oe
.
editor
Input
,
model
.
positionOfGroup
(
oe
.
editorG
roup
),
positionOfTargetGroup
,
{
preserveFocus
:
true
}));
this
.
editorGroupService
.
moveEditor
(
oe
.
editor
,
model
.
positionOfGroup
(
oe
.
g
roup
),
positionOfTargetGroup
,
{
preserveFocus
:
true
}));
this
.
editorGroupService
.
activateGroup
(
positionOfTargetGroup
);
}
}));
...
...
@@ -539,7 +539,7 @@ class OpenEditorRenderer implements IRenderer<OpenEditor, IOpenEditorTemplateDat
const
dragImage
=
document
.
createElement
(
'
div
'
);
e
.
dataTransfer
.
effectAllowed
=
'
copyMove
'
;
dragImage
.
className
=
'
monaco-tree-drag-image
'
;
dragImage
.
textContent
=
editorTemplate
.
openEditor
.
editor
Input
.
getName
();
dragImage
.
textContent
=
editorTemplate
.
openEditor
.
editor
.
getName
();
document
.
body
.
appendChild
(
dragImage
);
e
.
dataTransfer
.
setDragImage
(
dragImage
,
-
10
,
-
10
);
setTimeout
(()
=>
document
.
body
.
removeChild
(
dragImage
),
0
);
...
...
@@ -547,7 +547,7 @@ class OpenEditorRenderer implements IRenderer<OpenEditor, IOpenEditorTemplateDat
const
dragged
=
<
OpenEditor
[]
>
this
.
getSelectedElements
().
filter
(
e
=>
e
instanceof
OpenEditor
);
OpenEditorRenderer
.
DRAGGED_OPEN_EDITORS
=
dragged
;
if
(
editorTemplate
.
openEditor
&&
editorTemplate
.
openEditor
.
editor
Input
)
{
if
(
editorTemplate
.
openEditor
&&
editorTemplate
.
openEditor
.
editor
)
{
// enables dropping editor resource path into text controls
e
.
dataTransfer
.
setData
(
DataTransfers
.
TEXT
,
dragged
.
map
(
d
=>
d
.
getResource
()).
map
(
resource
=>
resource
.
scheme
===
'
file
'
?
getPathLabel
(
resource
)
:
resource
.
toString
()).
join
(
'
\n
'
));
...
...
@@ -574,11 +574,11 @@ class OpenEditorRenderer implements IRenderer<OpenEditor, IOpenEditorTemplateDat
dom
.
removeClass
(
container
,
'
focused
'
);
if
(
OpenEditorRenderer
.
DRAGGED_OPEN_EDITORS
)
{
const
model
=
this
.
editorGroupService
.
getStacksModel
();
const
positionOfTargetGroup
=
model
.
positionOfGroup
(
editorTemplate
.
openEditor
.
editorG
roup
);
const
index
=
editorTemplate
.
openEditor
.
editorGroup
.
indexOf
(
editorTemplate
.
openEditor
.
editorInput
);
const
positionOfTargetGroup
=
model
.
positionOfGroup
(
editorTemplate
.
openEditor
.
g
roup
);
const
index
=
editorTemplate
.
openEditor
.
group
.
indexOf
(
editorTemplate
.
openEditor
.
editor
);
OpenEditorRenderer
.
DRAGGED_OPEN_EDITORS
.
forEach
(
oe
=>
this
.
editorGroupService
.
moveEditor
(
oe
.
editor
Input
,
model
.
positionOfGroup
(
oe
.
editorG
roup
),
positionOfTargetGroup
,
{
index
,
preserveFocus
:
true
}));
this
.
editorGroupService
.
moveEditor
(
oe
.
editor
,
model
.
positionOfGroup
(
oe
.
g
roup
),
positionOfTargetGroup
,
{
index
,
preserveFocus
:
true
}));
this
.
editorGroupService
.
activateGroup
(
positionOfTargetGroup
);
}
}));
...
...
@@ -592,12 +592,12 @@ class OpenEditorRenderer implements IRenderer<OpenEditor, IOpenEditorTemplateDat
renderElement
(
editor
:
OpenEditor
,
index
:
number
,
templateData
:
IOpenEditorTemplateData
):
void
{
templateData
.
openEditor
=
editor
;
editor
.
isDirty
()
?
dom
.
addClass
(
templateData
.
container
,
'
dirty
'
)
:
dom
.
removeClass
(
templateData
.
container
,
'
dirty
'
);
templateData
.
root
.
setEditor
(
editor
.
editor
Input
,
{
templateData
.
root
.
setEditor
(
editor
.
editor
,
{
italic
:
editor
.
isPreview
(),
extraClasses
:
[
'
open-editor
'
],
fileDecorations
:
this
.
configurationService
.
getValue
<
IFilesConfiguration
>
().
explorer
.
decorations
});
templateData
.
actionBar
.
context
=
{
group
:
editor
.
editorGroup
,
editor
:
editor
.
editorInput
};
templateData
.
actionBar
.
context
=
{
group
:
editor
.
group
,
editor
:
editor
.
editor
};
}
disposeTemplate
(
templateData
:
IOpenEditorTemplateData
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录