Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0483997d
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
0483997d
编写于
5月 20, 2020
作者:
I
Isidor Nikolic
提交者:
GitHub
5月 20, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #98236 from microsoft/isidorn/editor-aria-preview
editor: conoslidte computing of editor aria labels
上级
4c1c26d5
084b8148
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
42 deletion
+41
-42
src/vs/workbench/browser/parts/editor/editor.ts
src/vs/workbench/browser/parts/editor/editor.ts
+19
-0
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+5
-5
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
+0
-13
src/vs/workbench/browser/parts/editor/textEditor.ts
src/vs/workbench/browser/parts/editor/textEditor.ts
+2
-12
src/vs/workbench/browser/parts/editor/textResourceEditor.ts
src/vs/workbench/browser/parts/editor/textResourceEditor.ts
+0
-6
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+9
-0
src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts
...workbench/contrib/files/browser/editors/textFileEditor.ts
+1
-6
src/vs/workbench/services/untitled/common/untitledTextEditorInput.ts
...bench/services/untitled/common/untitledTextEditorInput.ts
+5
-0
未找到文件。
src/vs/workbench/browser/parts/editor/editor.ts
浏览文件 @
0483997d
...
...
@@ -14,6 +14,7 @@ import { ISerializableView } from 'vs/base/browser/ui/grid/grid';
import
{
getCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorService
,
IResourceEditorInputType
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
localize
}
from
'
vs/nls
'
;
export
const
EDITOR_TITLE_HEIGHT
=
35
;
...
...
@@ -41,6 +42,24 @@ export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = {
splitSizing
:
'
distribute
'
};
export
function
computeEditorAriaLabel
(
input
:
IEditorInput
,
group
:
IEditorGroup
|
undefined
,
groupCount
:
number
):
string
{
let
ariaLabel
=
input
.
getAriaLabel
();
if
(
group
&&
!
group
.
isPinned
(
input
))
{
ariaLabel
=
`
${
ariaLabel
}
,
${
localize
(
'
preview
'
,
"
preview
"
)}
`
;
}
if
(
group
&&
group
.
isSticky
(
input
))
{
ariaLabel
=
`
${
ariaLabel
}
,
${
localize
(
'
pinned
'
,
"
pinned
"
)}
`
;
}
// Apply group information to help identify in
// which group we are (only if more than one group
// is actually opened)
if
(
group
&&
groupCount
>
1
)
{
ariaLabel
=
`
${
ariaLabel
}
,
${
group
.
ariaLabel
}
`
;
}
return
ariaLabel
;
}
export
function
impactsEditorPartOptions
(
event
:
IConfigurationChangeEvent
):
boolean
{
return
event
.
affectsConfiguration
(
'
workbench.editor
'
)
||
event
.
affectsConfiguration
(
'
workbench.iconTheme
'
);
}
...
...
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
0483997d
...
...
@@ -31,10 +31,10 @@ import { ResourcesDropHandler, DraggedEditorIdentifier, DraggedEditorGroupIdenti
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
MergeGroupMode
,
IMergeGroupOptions
,
GroupsArrangement
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
MergeGroupMode
,
IMergeGroupOptions
,
GroupsArrangement
,
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
addClass
,
addDisposableListener
,
hasClass
,
EventType
,
EventHelper
,
removeClass
,
Dimension
,
scheduleAtNextAnimationFrame
,
findParentWithClass
,
clearNode
}
from
'
vs/base/browser/dom
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IEditorGroupsAccessor
,
IEditorGroupView
,
EditorServiceImpl
,
EDITOR_TITLE_HEIGHT
}
from
'
vs/workbench/browser/parts/editor/editor
'
;
import
{
IEditorGroupsAccessor
,
IEditorGroupView
,
EditorServiceImpl
,
EDITOR_TITLE_HEIGHT
,
computeEditorAriaLabel
}
from
'
vs/workbench/browser/parts/editor/editor
'
;
import
{
CloseOneEditorAction
}
from
'
vs/workbench/browser/parts/editor/editorActions
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
BreadcrumbsControl
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsControl
'
;
...
...
@@ -102,7 +102,8 @@ export class TabsTitleControl extends TitleControl {
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IFileService
fileService
:
IFileService
,
@
IEditorService
private
readonly
editorService
:
EditorServiceImpl
,
@
IPathService
private
readonly
pathService
:
IPathService
@
IPathService
private
readonly
pathService
:
IPathService
,
@
IEditorGroupsService
private
readonly
editorGroupService
:
IEditorGroupsService
)
{
super
(
parent
,
accessor
,
group
,
contextMenuService
,
instantiationService
,
contextKeyService
,
keybindingService
,
telemetryService
,
notificationService
,
menuService
,
quickInputService
,
themeService
,
extensionService
,
configurationService
,
fileService
);
...
...
@@ -881,14 +882,13 @@ export class TabsTitleControl extends TitleControl {
private
computeTabLabels
():
void
{
const
{
labelFormat
}
=
this
.
accessor
.
partOptions
;
const
{
verbosity
,
shortenDuplicates
}
=
this
.
getLabelConfigFlags
(
labelFormat
);
// Build labels and descriptions for each editor
const
labels
=
this
.
group
.
editors
.
map
(
editor
=>
({
editor
,
name
:
editor
.
getName
(),
description
:
editor
.
getDescription
(
verbosity
),
title
:
withNullAsUndefined
(
editor
.
getTitle
(
Verbosity
.
LONG
)),
ariaLabel
:
editor
.
isReadonly
()
?
localize
(
'
readonlyEditor
'
,
"
{0} readonly
"
,
editor
.
getTitle
(
Verbosity
.
SHORT
))
:
editor
.
getTitle
(
Verbosity
.
SHORT
)
ariaLabel
:
computeEditorAriaLabel
(
editor
,
this
.
group
,
this
.
editorGroupService
.
count
)
}));
// Shorten labels as needed
...
...
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
浏览文件 @
0483997d
...
...
@@ -215,19 +215,6 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditorPan
return
options
;
}
protected
getAriaLabel
():
string
{
let
ariaLabel
:
string
;
const
inputName
=
this
.
input
?.
getName
();
if
(
this
.
input
?.
isReadonly
())
{
ariaLabel
=
inputName
?
nls
.
localize
(
'
readonlyEditorWithInputAriaLabel
'
,
"
{0} readonly compare
"
,
inputName
)
:
nls
.
localize
(
'
readonlyEditorAriaLabel
'
,
"
Readonly compare
"
);
}
else
{
ariaLabel
=
inputName
?
nls
.
localize
(
'
editableEditorWithInputAriaLabel
'
,
"
{0} compare
"
,
inputName
)
:
nls
.
localize
(
'
editableEditorAriaLabel
'
,
"
Compare
"
);
}
return
ariaLabel
;
}
private
isFileBinaryError
(
error
:
Error
[]):
boolean
;
private
isFileBinaryError
(
error
:
Error
):
boolean
;
private
isFileBinaryError
(
error
:
Error
|
Error
[]):
boolean
{
...
...
src/vs/workbench/browser/parts/editor/textEditor.ts
浏览文件 @
0483997d
...
...
@@ -23,6 +23,7 @@ import { isCodeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
import
{
IEditorGroupsService
,
IEditorGroup
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
computeEditorAriaLabel
}
from
'
vs/workbench/browser/parts/editor/editor
'
;
export
interface
IEditorConfiguration
{
editor
:
object
;
...
...
@@ -102,16 +103,7 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditorPa
}
private
computeAriaLabel
():
string
{
let
ariaLabel
=
this
.
getAriaLabel
();
// Apply group information to help identify in
// which group we are (only if more than one group
// is actually opened)
if
(
ariaLabel
&&
this
.
group
&&
this
.
editorGroupService
.
count
>
1
)
{
ariaLabel
=
localize
(
'
editorLabelWithGroup
'
,
"
{0}, {1}
"
,
ariaLabel
,
this
.
group
.
ariaLabel
);
}
return
ariaLabel
;
return
this
.
_input
?
computeEditorAriaLabel
(
this
.
_input
,
this
.
group
,
this
.
editorGroupService
.
count
)
:
localize
(
'
editor
'
,
"
Editor
"
);
}
protected
getConfigurationOverrides
():
IEditorOptions
{
...
...
@@ -303,8 +295,6 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditorPa
return
undefined
;
}
protected
abstract
getAriaLabel
():
string
;
dispose
():
void
{
this
.
lastAppliedEditorOptions
=
undefined
;
...
...
src/vs/workbench/browser/parts/editor/textResourceEditor.ts
浏览文件 @
0483997d
...
...
@@ -25,7 +25,6 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
PLAINTEXT_MODE_ID
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
EditorOption
,
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
basenameOrAuthority
}
from
'
vs/base/common/resources
'
;
import
{
ModelConstants
}
from
'
vs/editor/common/model
'
;
/**
...
...
@@ -108,11 +107,6 @@ export class AbstractTextResourceEditor extends BaseTextEditor {
}
}
protected
getAriaLabel
():
string
{
const
inputName
=
this
.
input
instanceof
UntitledTextEditorInput
?
basenameOrAuthority
(
this
.
input
.
resource
)
:
this
.
input
?.
getName
()
||
nls
.
localize
(
'
writeableEditorAriaLabel
'
,
"
Editor
"
);
return
this
.
input
?.
isReadonly
()
?
nls
.
localize
(
'
readonlyEditor
'
,
"
{0} readonly
"
,
inputName
)
:
inputName
;
}
/**
* Reveals the last line of this editor if it has a model set.
*/
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
0483997d
...
...
@@ -403,6 +403,11 @@ export interface IEditorInput extends IDisposable {
*/
getTitle
(
verbosity
?:
Verbosity
):
string
|
undefined
;
/**
* Returns the aria label to be read out by a screen reader.
*/
getAriaLabel
():
string
;
/**
* Resolves the input.
*/
...
...
@@ -512,6 +517,10 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
return
this
.
getName
();
}
getAriaLabel
():
string
{
return
this
.
getTitle
(
Verbosity
.
SHORT
);
}
/**
* Returns the preferred editor for this input. A list of candidate editors is passed in that whee registered
* for the input. This allows subclasses to decide late which editor to use for the input on a case by case basis.
...
...
src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts
浏览文件 @
0483997d
...
...
@@ -12,7 +12,7 @@ import { Action } from 'vs/base/common/actions';
import
{
VIEWLET_ID
,
TEXT_FILE_EDITOR_ID
,
IExplorerService
}
from
'
vs/workbench/contrib/files/common/files
'
;
import
{
ITextFileService
,
TextFileOperationError
,
TextFileOperationResult
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
BaseTextEditor
,
IEditorConfiguration
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
EditorOptions
,
TextEditorOptions
,
IEditorCloseEvent
,
Verbosity
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorOptions
,
TextEditorOptions
,
IEditorCloseEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
BinaryEditorModel
}
from
'
vs/workbench/common/editor/binaryEditorModel
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/contrib/files/common/editors/fileEditorInput
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
...
...
@@ -245,11 +245,6 @@ export class TextFileEditor extends BaseTextEditor {
}
}
protected
getAriaLabel
():
string
{
const
title
=
this
.
input
?.
getTitle
(
Verbosity
.
SHORT
)
||
nls
.
localize
(
'
fileEditorAriaLabel
'
,
"
editor
"
);
return
this
.
input
?.
isReadonly
()
?
nls
.
localize
(
'
readonlyEditor
'
,
"
{0} readonly
"
,
title
)
:
title
;
}
clearInput
():
void
{
// Update/clear editor view state in settings
...
...
src/vs/workbench/services/untitled/common/untitledTextEditorInput.ts
浏览文件 @
0483997d
...
...
@@ -12,6 +12,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IFilesConfigurationService
}
from
'
vs/workbench/services/filesConfiguration/common/filesConfigurationService
'
;
import
{
basenameOrAuthority
}
from
'
vs/base/common/resources
'
;
/**
* An editor input to be used for untitled text buffers.
...
...
@@ -50,6 +51,10 @@ export class UntitledTextEditorInput extends TextResourceEditorInput implements
return
UntitledTextEditorInput
.
ID
;
}
get
ariaLabel
():
string
{
return
basenameOrAuthority
(
this
.
resource
);
}
getName
():
string
{
return
this
.
model
.
name
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录