Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
557d444f
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,发现更多精彩内容 >>
提交
557d444f
编写于
11月 13, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
open editors - adopt working copy service and track unsaved properly (#84672)
上级
44a7079e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
15 deletion
+19
-15
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
.../workbench/contrib/files/browser/views/openEditorsView.ts
+17
-14
src/vs/workbench/contrib/testCustomEditors/browser/testCustomEditors.ts
...ch/contrib/testCustomEditors/browser/testCustomEditors.ts
+2
-1
未找到文件。
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
浏览文件 @
557d444f
...
...
@@ -15,8 +15,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
IEditorInput
,
Verbosity
}
from
'
vs/workbench/common/editor
'
;
import
{
SaveAllAction
,
SaveAllInGroupAction
,
CloseGroupAction
}
from
'
vs/workbench/contrib/files/browser/fileActions
'
;
import
{
OpenEditorsFocusedContext
,
ExplorerFocusedContext
,
IFilesConfiguration
,
OpenEditor
}
from
'
vs/workbench/contrib/files/common/files
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IUntitledTextEditorService
}
from
'
vs/workbench/services/untitled/common/untitledTextEditorService
'
;
import
{
CloseAllEditorsAction
,
CloseEditorAction
}
from
'
vs/workbench/browser/parts/editor/editorActions
'
;
import
{
ToggleEditorLayoutAction
}
from
'
vs/workbench/browser/actions/layoutActions
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -43,7 +41,7 @@ import { ElementsDragAndDropData, DesktopDragAndDropData } from 'vs/base/browser
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
withNullAsUndefined
,
withUndefinedAsNull
}
from
'
vs/base/common/types
'
;
import
{
isWeb
}
from
'
vs/base/common/platform
'
;
import
{
I
AutoSaveConfigurationService
,
AutoSaveMode
}
from
'
vs/workbench/services/autoSaveConfiguration/common/autoSaveConfiguration
Service
'
;
import
{
I
WorkingCopyService
}
from
'
vs/workbench/services/workingCopy/common/workingCopy
Service
'
;
const
$
=
dom
.
$
;
...
...
@@ -68,17 +66,15 @@ export class OpenEditorsView extends ViewletPanel {
options
:
IViewletViewOptions
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
ITextFileService
private
readonly
textFileService
:
ITextFileService
,
@
IEditorService
private
readonly
editorService
:
IEditorService
,
@
IEditorGroupsService
private
readonly
editorGroupService
:
IEditorGroupsService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IUntitledTextEditorService
private
readonly
untitledTextEditorService
:
IUntitledTextEditorService
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
,
@
IThemeService
private
readonly
themeService
:
IThemeService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
@
IMenuService
private
readonly
menuService
:
IMenuService
,
@
I
AutoSaveConfigurationService
private
readonly
autoSaveConfigurationService
:
IAutoSaveConfiguration
Service
@
I
WorkingCopyService
private
readonly
workingCopyService
:
IWorkingCopy
Service
)
{
super
({
...(
options
as
IViewletPanelOptions
),
...
...
@@ -102,11 +98,7 @@ export class OpenEditorsView extends ViewletPanel {
this
.
_register
(
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
this
.
onConfigurationChange
(
e
)));
// Handle dirty counter
this
.
_register
(
this
.
untitledTextEditorService
.
onDidChangeDirty
(()
=>
this
.
updateDirtyIndicator
()));
this
.
_register
(
this
.
textFileService
.
models
.
onModelsDirty
(()
=>
this
.
updateDirtyIndicator
()));
this
.
_register
(
this
.
textFileService
.
models
.
onModelsSaved
(()
=>
this
.
updateDirtyIndicator
()));
this
.
_register
(
this
.
textFileService
.
models
.
onModelsSaveError
(()
=>
this
.
updateDirtyIndicator
()));
this
.
_register
(
this
.
textFileService
.
models
.
onModelsReverted
(()
=>
this
.
updateDirtyIndicator
()));
this
.
_register
(
this
.
workingCopyService
.
onDidChangeDirty
(()
=>
this
.
updateDirtyIndicator
()));
}
private
registerUpdateEvents
():
void
{
...
...
@@ -248,7 +240,7 @@ export class OpenEditorsView extends ViewletPanel {
const
element
=
e
.
elements
.
length
?
e
.
elements
[
0
]
:
undefined
;
if
(
element
instanceof
OpenEditor
)
{
const
resource
=
element
.
getResource
();
this
.
dirtyEditorFocusedContext
.
set
(
this
.
textFileService
.
isDirty
(
resource
));
this
.
dirtyEditorFocusedContext
.
set
(
element
.
editor
.
isDirty
(
));
this
.
resourceContext
.
set
(
withUndefinedAsNull
(
resource
));
}
else
if
(
!!
element
)
{
this
.
groupFocusedContext
.
set
(
true
);
...
...
@@ -415,8 +407,7 @@ export class OpenEditorsView extends ViewletPanel {
}
private
updateDirtyIndicator
():
void
{
let
dirty
=
this
.
autoSaveConfigurationService
.
getAutoSaveMode
()
!==
AutoSaveMode
.
AFTER_SHORT_DELAY
?
this
.
textFileService
.
getDirty
().
length
:
this
.
untitledTextEditorService
.
getDirty
().
length
;
let
dirty
=
this
.
dirtyCount
;
if
(
dirty
===
0
)
{
dom
.
addClass
(
this
.
dirtyCountElement
,
'
hidden
'
);
}
else
{
...
...
@@ -425,6 +416,18 @@ export class OpenEditorsView extends ViewletPanel {
}
}
private
get
dirtyCount
():
number
{
let
dirtyCount
=
0
;
for
(
const
element
of
this
.
elements
)
{
if
(
element
instanceof
OpenEditor
&&
element
.
editor
.
isDirty
())
{
dirtyCount
++
;
}
}
return
dirtyCount
;
}
private
get
elementCount
():
number
{
return
this
.
editorGroupService
.
groups
.
map
(
g
=>
g
.
count
)
.
reduce
((
first
,
second
)
=>
first
+
second
,
this
.
showGroups
?
this
.
editorGroupService
.
groups
.
length
:
0
);
...
...
src/vs/workbench/contrib/testCustomEditors/browser/testCustomEditors.ts
浏览文件 @
557d444f
...
...
@@ -25,9 +25,10 @@ import { generateUuid } from 'vs/base/common/uuid';
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
editorBackground
,
editorForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
IWorkingCopy
,
IWorkingCopyService
}
from
'
vs/workbench/services/workingCopy/common/workingCopyService
'
;
import
{
env
}
from
'
vs/base/common/process
'
;
const
CUSTOM_SCHEME
=
'
testCustomEditor
'
;
const
ENABLE
=
false
;
const
ENABLE
=
!!
env
[
'
VSCODE_DEV
'
]
;
class
TestCustomEditorsAction
extends
Action
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录