Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b36f377b
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,发现更多精彩内容 >>
提交
b36f377b
编写于
3月 13, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compare untitled files: title (fix #92556)
上级
955ff025
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
96 addition
and
30 deletion
+96
-30
src/vs/workbench/browser/labels.ts
src/vs/workbench/browser/labels.ts
+35
-10
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
+13
-4
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+5
-2
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+21
-8
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
.../workbench/contrib/files/browser/views/openEditorsView.ts
+1
-1
src/vs/workbench/electron-browser/window.ts
src/vs/workbench/electron-browser/window.ts
+2
-2
src/vs/workbench/test/browser/parts/editor/editor.test.ts
src/vs/workbench/test/browser/parts/editor/editor.test.ts
+19
-3
未找到文件。
src/vs/workbench/browser/labels.ts
浏览文件 @
b36f377b
...
...
@@ -24,11 +24,23 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
interface
IResourceLabelProps
{
resource
?:
URI
;
resource
?:
URI
|
{
master
?:
URI
,
detail
?:
URI
}
;
name
?:
string
|
string
[];
description
?:
string
;
}
function
toResource
(
props
:
IResourceLabelProps
|
undefined
):
URI
|
undefined
{
if
(
!
props
||
!
props
.
resource
)
{
return
undefined
;
}
if
(
URI
.
isUri
(
props
.
resource
))
{
return
props
.
resource
;
}
return
props
.
resource
.
master
;
}
export
interface
IResourceLabelOptions
extends
IIconLabelValueOptions
{
fileKind
?:
FileKind
;
fileDecorations
?:
{
colors
:
boolean
,
badges
:
boolean
};
...
...
@@ -289,11 +301,16 @@ class ResourceLabelWidget extends IconLabel {
}
notifyFileDecorationsChanges
(
e
:
IResourceDecorationChangeEvent
):
void
{
if
(
!
this
.
options
||
!
this
.
label
||
!
this
.
label
.
resource
)
{
if
(
!
this
.
options
)
{
return
;
}
if
(
this
.
options
.
fileDecorations
&&
e
.
affectsResource
(
this
.
label
.
resource
))
{
const
resource
=
toResource
(
this
.
label
);
if
(
!
resource
)
{
return
;
}
if
(
this
.
options
.
fileDecorations
&&
e
.
affectsResource
(
resource
))
{
this
.
render
(
false
);
}
}
...
...
@@ -311,13 +328,13 @@ class ResourceLabelWidget extends IconLabel {
}
notifyFormattersChange
(
scheme
:
string
):
void
{
if
(
t
his
.
label
?.
resource
?.
scheme
===
scheme
)
{
if
(
t
oResource
(
this
.
label
)
?.
scheme
===
scheme
)
{
this
.
render
(
false
);
}
}
notifyUntitledLabelChange
(
resource
:
URI
):
void
{
if
(
isEqual
(
resource
,
t
his
.
label
?.
resource
))
{
if
(
isEqual
(
resource
,
t
oResource
(
this
.
label
)
))
{
this
.
render
(
false
);
}
}
...
...
@@ -347,7 +364,10 @@ class ResourceLabelWidget extends IconLabel {
}
setResource
(
label
:
IResourceLabelProps
,
options
:
IResourceLabelOptions
=
Object
.
create
(
null
)):
void
{
if
(
label
.
resource
?.
scheme
===
Schemas
.
untitled
)
{
const
resource
=
toResource
(
this
.
label
);
const
isMasterDetail
=
this
.
label
?.
resource
&&
!
URI
.
isUri
(
this
.
label
.
resource
);
if
(
!
isMasterDetail
&&
resource
?.
scheme
===
Schemas
.
untitled
)
{
// Untitled labels are very dynamic because they may change
// whenever the content changes (unless a path is associated).
// As such we always ask the actual editor for it's name and
...
...
@@ -355,7 +375,11 @@ class ResourceLabelWidget extends IconLabel {
// provided. If they are not provided from the label we got
// we assume that the client does not want to display them
// and as such do not override.
const
untitledModel
=
this
.
textFileService
.
untitled
.
get
(
label
.
resource
);
//
// We do not touch the label if it represents a master-detail
// because in that case we expect it to carry a proper label
// and description.
const
untitledModel
=
this
.
textFileService
.
untitled
.
get
(
resource
);
if
(
untitledModel
&&
!
untitledModel
.
hasAssociatedFilePath
)
{
if
(
typeof
label
.
name
===
'
string
'
)
{
label
.
name
=
untitledModel
.
name
;
...
...
@@ -415,7 +439,7 @@ class ResourceLabelWidget extends IconLabel {
}
private
hasPathLabelChanged
(
newLabel
:
IResourceLabelProps
,
newOptions
?:
IResourceLabelOptions
):
boolean
{
const
newResource
=
newLabel
?
newLabel
.
resource
:
undefined
;
const
newResource
=
toResource
(
newLabel
)
;
return
!!
newResource
&&
this
.
computedPathLabel
!==
this
.
labelService
.
getUriLabel
(
newResource
);
}
...
...
@@ -444,7 +468,8 @@ class ResourceLabelWidget extends IconLabel {
}
if
(
this
.
label
)
{
const
detectedModeId
=
this
.
label
.
resource
?
withNullAsUndefined
(
detectModeId
(
this
.
modelService
,
this
.
modeService
,
this
.
label
.
resource
))
:
undefined
;
const
resource
=
toResource
(
this
.
label
);
const
detectedModeId
=
resource
?
withNullAsUndefined
(
detectModeId
(
this
.
modelService
,
this
.
modeService
,
resource
))
:
undefined
;
if
(
this
.
lastKnownDetectedModeId
!==
detectedModeId
)
{
clearIconCache
=
true
;
this
.
lastKnownDetectedModeId
=
detectedModeId
;
...
...
@@ -470,7 +495,7 @@ class ResourceLabelWidget extends IconLabel {
domId
:
this
.
options
?.
domId
};
const
resource
=
t
his
.
label
.
resource
;
const
resource
=
t
oResource
(
this
.
label
)
;
const
label
=
this
.
label
.
name
;
if
(
this
.
options
&&
typeof
this
.
options
.
title
===
'
string
'
)
{
...
...
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
浏览文件 @
b36f377b
...
...
@@ -260,9 +260,6 @@ export class NoTabsTitleControl extends TitleControl {
this
.
updateEditorDirty
(
editor
);
// Editor Label
const
resource
=
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
});
const
name
=
editor
.
getName
();
const
{
labelFormat
}
=
this
.
accessor
.
partOptions
;
let
description
:
string
;
if
(
this
.
breadcrumbsControl
&&
!
this
.
breadcrumbsControl
.
isHidden
())
{
...
...
@@ -278,7 +275,19 @@ export class NoTabsTitleControl extends TitleControl {
title
=
''
;
// dont repeat what is already shown
}
editorLabel
.
setResource
({
name
,
description
,
resource
},
{
title
:
typeof
title
===
'
string
'
?
title
:
undefined
,
italic
:
!
isEditorPinned
,
extraClasses
:
[
'
no-tabs
'
,
'
title-label
'
]
});
editorLabel
.
setResource
(
{
resource
:
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
}),
name
:
editor
.
getName
(),
description
},
{
title
,
italic
:
!
isEditorPinned
,
extraClasses
:
[
'
no-tabs
'
,
'
title-label
'
]
}
);
if
(
isGroupActive
)
{
editorLabel
.
element
.
style
.
color
=
this
.
getColor
(
TAB_ACTIVE_FOREGROUND
)
||
''
;
}
else
{
...
...
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
b36f377b
...
...
@@ -963,10 +963,13 @@ export class TabsTitleControl extends TitleControl {
tabContainer
.
title
=
title
;
// Label
const
resource
=
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
});
tabLabelWidget
.
setResource
({
name
,
description
,
resource
},
{
title
,
extraClasses
:
[
'
tab-label
'
],
italic
:
!
this
.
group
.
isPinned
(
editor
)
});
tabLabelWidget
.
setResource
(
{
name
,
description
,
resource
:
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
})
},
{
title
,
extraClasses
:
[
'
tab-label
'
],
italic
:
!
this
.
group
.
isPinned
(
editor
)
}
);
// Tests helper
const
resource
=
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
});
if
(
resource
)
{
tabContainer
.
setAttribute
(
'
data-resource-name
'
,
basenameOrAuthority
(
resource
));
}
else
{
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
b36f377b
...
...
@@ -1319,7 +1319,8 @@ export interface IEditorPartOptionsChangeEvent {
export
enum
SideBySideEditor
{
MASTER
=
1
,
DETAILS
=
2
DETAILS
=
2
,
BOTH
=
3
}
export
interface
IResourceOptions
{
...
...
@@ -1327,12 +1328,22 @@ export interface IResourceOptions {
filterByScheme
?:
string
|
string
[];
}
export
function
toResource
(
editor
:
IEditorInput
|
undefined
,
options
?:
IResourceOptions
):
URI
|
undefined
{
export
function
toResource
(
editor
:
IEditorInput
|
undefined
):
URI
|
undefined
;
export
function
toResource
(
editor
:
IEditorInput
|
undefined
,
options
:
IResourceOptions
&
{
supportSideBySide
?:
SideBySideEditor
.
MASTER
|
SideBySideEditor
.
DETAILS
}):
URI
|
undefined
;
export
function
toResource
(
editor
:
IEditorInput
|
undefined
,
options
:
IResourceOptions
&
{
supportSideBySide
:
SideBySideEditor
.
BOTH
}):
URI
|
{
master
?:
URI
,
detail
?:
URI
}
|
undefined
;
export
function
toResource
(
editor
:
IEditorInput
|
undefined
,
options
?:
IResourceOptions
):
URI
|
{
master
?:
URI
,
detail
?:
URI
}
|
undefined
{
if
(
!
editor
)
{
return
undefined
;
}
if
(
options
?.
supportSideBySide
&&
editor
instanceof
SideBySideEditorInput
)
{
if
(
options
?.
supportSideBySide
===
SideBySideEditor
.
BOTH
)
{
return
{
master
:
toResource
(
editor
.
master
,
{
filterByScheme
:
options
.
filterByScheme
}),
detail
:
toResource
(
editor
.
details
,
{
filterByScheme
:
options
.
filterByScheme
})
};
}
editor
=
options
.
supportSideBySide
===
SideBySideEditor
.
MASTER
?
editor
.
master
:
editor
.
details
;
}
...
...
@@ -1341,13 +1352,15 @@ export function toResource(editor: IEditorInput | undefined, options?: IResource
return
resource
;
}
if
(
Array
.
isArray
(
options
.
filterByScheme
)
&&
options
.
filterByScheme
.
some
(
scheme
=>
resource
.
scheme
===
scheme
))
{
if
(
Array
.
isArray
(
options
.
filterByScheme
))
{
if
(
options
.
filterByScheme
.
some
(
scheme
=>
resource
.
scheme
===
scheme
))
{
return
resource
;
}
}
else
{
if
(
options
.
filterByScheme
===
resource
.
scheme
)
{
return
resource
;
}
}
return
undefined
;
}
...
...
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
浏览文件 @
b36f377b
...
...
@@ -592,7 +592,7 @@ class OpenEditorRenderer implements IListRenderer<OpenEditor, IOpenEditorTemplat
templateData
.
actionRunner
.
editor
=
openedEditor
;
editor
.
isDirty
()
&&
!
editor
.
isSaving
()
?
dom
.
addClass
(
templateData
.
container
,
'
dirty
'
)
:
dom
.
removeClass
(
templateData
.
container
,
'
dirty
'
);
templateData
.
root
.
setResource
({
resource
:
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
}),
resource
:
toResource
(
editor
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
}),
name
:
editor
.
getName
(),
description
:
editor
.
getDescription
(
Verbosity
.
MEDIUM
)
},
{
...
...
src/vs/workbench/electron-browser/window.ts
浏览文件 @
b36f377b
...
...
@@ -251,10 +251,10 @@ export class NativeWindow extends Disposable {
const
file
=
toResource
(
this
.
editorService
.
activeEditor
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
,
filterByScheme
:
Schemas
.
file
});
// Represented Filename
this
.
updateRepresentedFilename
(
file
?
file
.
fsPath
:
undefined
);
this
.
updateRepresentedFilename
(
file
?.
fsPath
);
// Custom title menu
this
.
provideCustomTitleContextMenu
(
file
?
file
.
fsPath
:
undefined
);
this
.
provideCustomTitleContextMenu
(
file
?.
fsPath
);
}));
}
...
...
src/vs/workbench/test/browser/parts/editor/editor.test.ts
浏览文件 @
b36f377b
...
...
@@ -35,6 +35,8 @@ suite('Workbench editor', () => {
assert
.
equal
(
toResource
(
untitled
)
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
untitled
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
untitled
,
{
supportSideBySide
:
SideBySideEditor
.
DETAILS
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
untitled
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
untitled
,
{
filterByScheme
:
Schemas
.
untitled
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
untitled
,
{
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
ok
(
!
toResource
(
untitled
,
{
filterByScheme
:
Schemas
.
file
}));
...
...
@@ -43,6 +45,8 @@ suite('Workbench editor', () => {
assert
.
equal
(
toResource
(
file
)
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
supportSideBySide
:
SideBySideEditor
.
DETAILS
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
filterByScheme
:
Schemas
.
file
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
ok
(
!
toResource
(
file
,
{
filterByScheme
:
Schemas
.
untitled
}));
...
...
@@ -52,8 +56,20 @@ suite('Workbench editor', () => {
assert
.
ok
(
!
toResource
(
diffEditorInput
));
assert
.
ok
(
!
toResource
(
diffEditorInput
,
{
filterByScheme
:
Schemas
.
file
}));
assert
.
equal
(
toResource
(
file
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
,
filterByScheme
:
Schemas
.
file
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
file
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
,
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
,
filterByScheme
:
Schemas
.
file
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
MASTER
,
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
!
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
(
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
DETAILS
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
DETAILS
,
filterByScheme
:
Schemas
.
untitled
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
(
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
DETAILS
,
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
!
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
((
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
})
as
{
master
:
URI
,
detail
:
URI
}).
master
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
((
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
,
filterByScheme
:
Schemas
.
file
})
as
{
master
:
URI
,
detail
:
URI
}).
master
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
((
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
,
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
as
{
master
:
URI
,
detail
:
URI
}).
master
.
toString
(),
file
.
resource
.
toString
());
assert
.
equal
((
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
})
as
{
master
:
URI
,
detail
:
URI
}).
detail
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
((
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
,
filterByScheme
:
Schemas
.
untitled
})
as
{
master
:
URI
,
detail
:
URI
}).
detail
.
toString
(),
untitled
.
resource
.
toString
());
assert
.
equal
((
toResource
(
diffEditorInput
,
{
supportSideBySide
:
SideBySideEditor
.
BOTH
,
filterByScheme
:
[
Schemas
.
file
,
Schemas
.
untitled
]
})
as
{
master
:
URI
,
detail
:
URI
}).
detail
.
toString
(),
untitled
.
resource
.
toString
());
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录