Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ea0d487d
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,发现更多精彩内容 >>
提交
ea0d487d
编写于
2月 11, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null check quickOpenController
上级
24a42d3a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
32 deletion
+38
-32
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+2
-0
src/vs/base/parts/quickopen/browser/quickOpenWidget.ts
src/vs/base/parts/quickopen/browser/quickOpenWidget.ts
+3
-3
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
.../workbench/browser/parts/quickopen/quickOpenController.ts
+33
-29
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
ea0d487d
...
...
@@ -462,6 +462,8 @@
"./vs/workbench/browser/parts/quickinput/quickInputBox.ts"
,
"./vs/workbench/browser/parts/quickinput/quickInputList.ts"
,
"./vs/workbench/browser/parts/quickinput/quickInputUtils.ts"
,
"./vs/workbench/browser/parts/quickopen/quickOpenActions.ts"
,
"./vs/workbench/browser/parts/quickopen/quickOpenController.ts"
,
"./vs/workbench/browser/parts/quickopen/quickopen.ts"
,
"./vs/workbench/browser/parts/sidebar/sidebarPart.ts"
,
"./vs/workbench/browser/parts/statusbar/statusbar.ts"
,
...
...
src/vs/base/parts/quickopen/browser/quickOpenWidget.ts
浏览文件 @
ea0d487d
...
...
@@ -639,7 +639,7 @@ export class QuickOpenWidget extends Disposable implements IModelProvider {
this
.
setInput
(
input
,
autoFocus
);
}
private
setInputAndLayout
(
input
:
IModel
<
any
>
,
autoFocus
:
IAutoFocus
):
void
{
private
setInputAndLayout
(
input
:
IModel
<
any
>
,
autoFocus
?
:
IAutoFocus
):
void
{
this
.
treeContainer
.
style
.
height
=
`
${
this
.
getHeight
(
input
)}
px`
;
this
.
tree
.
setInput
(
null
).
then
(()
=>
{
...
...
@@ -873,7 +873,7 @@ export class QuickOpenWidget extends Disposable implements IModelProvider {
}
}
setInput
(
input
:
IModel
<
any
>
,
autoFocus
:
IAutoFocus
,
ariaLabel
?:
string
):
void
{
setInput
(
input
:
IModel
<
any
>
,
autoFocus
?
:
IAutoFocus
,
ariaLabel
?:
string
):
void
{
if
(
!
this
.
isVisible
())
{
return
;
}
...
...
@@ -945,7 +945,7 @@ export class QuickOpenWidget extends Disposable implements IModelProvider {
return
this
.
inputBox
;
}
setExtraClass
(
clazz
:
string
):
void
{
setExtraClass
(
clazz
:
string
|
null
):
void
{
const
previousClass
=
this
.
element
.
getAttribute
(
'
quick-open-extra-class
'
);
if
(
previousClass
)
{
DOM
.
removeClasses
(
this
.
element
,
previousClass
);
...
...
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
浏览文件 @
ea0d487d
...
...
@@ -78,12 +78,12 @@ export class QuickOpenController extends Component implements IQuickOpenService
private
mapContextKeyToContext
:
{
[
id
:
string
]:
IContextKey
<
boolean
>
;
}
=
Object
.
create
(
null
);
private
handlerOnOpenCalled
:
{
[
prefix
:
string
]:
boolean
;
}
=
Object
.
create
(
null
);
private
promisesToCompleteOnHide
:
ValueCallback
[]
=
[];
private
previousActiveHandlerDescriptor
:
QuickOpenHandlerDescriptor
;
private
previousActiveHandlerDescriptor
:
QuickOpenHandlerDescriptor
|
null
;
private
actionProvider
=
new
ContributableActionProvider
();
private
closeOnFocusLost
:
boolean
;
private
searchInEditorHistory
:
boolean
;
private
editorHistoryHandler
:
EditorHistoryHandler
;
private
pendingGetResultsInvocation
:
CancellationTokenSource
;
private
pendingGetResultsInvocation
:
CancellationTokenSource
|
null
;
constructor
(
@
IEditorGroupsService
private
readonly
editorGroupService
:
IEditorGroupsService
,
...
...
@@ -165,7 +165,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
// Telemetry: log that quick open is shown and log the mode
const
registry
=
Registry
.
as
<
IQuickOpenRegistry
>
(
Extensions
.
Quickopen
);
const
handlerDescriptor
=
registry
.
getQuickOpenHandler
(
prefix
)
||
registry
.
getDefaultQuickOpenHandler
();
const
handlerDescriptor
=
(
prefix
?
registry
.
getQuickOpenHandler
(
prefix
)
:
undefined
)
||
registry
.
getDefaultQuickOpenHandler
();
// Trigger onOpen
this
.
resolveHandler
(
handlerDescriptor
);
...
...
@@ -206,7 +206,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
}
else
{
const
editorHistory
=
this
.
getEditorHistoryWithGroupLabel
();
if
(
editorHistory
.
getEntries
().
length
<
2
)
{
quickNavigateConfiguration
=
null
;
// If no entries can be shown, default to normal quick open mode
quickNavigateConfiguration
=
undefined
;
// If no entries can be shown, default to normal quick open mode
}
// Compute auto focus
...
...
@@ -270,7 +270,10 @@ export class QuickOpenController extends Component implements IQuickOpenService
// Complete promises that are waiting
while
(
this
.
promisesToCompleteOnHide
.
length
)
{
this
.
promisesToCompleteOnHide
.
pop
()(
true
);
const
callback
=
this
.
promisesToCompleteOnHide
.
pop
();
if
(
callback
)
{
callback
(
true
);
}
}
if
(
reason
!==
HideReason
.
FOCUS_LOST
)
{
...
...
@@ -297,7 +300,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
}
private
setQuickOpenContextKey
(
id
?:
string
):
void
{
let
key
:
IContextKey
<
boolean
>
;
let
key
:
IContextKey
<
boolean
>
|
undefined
;
if
(
id
)
{
key
=
this
.
mapContextKeyToContext
[
id
];
if
(
!
key
)
{
...
...
@@ -479,13 +482,13 @@ export class QuickOpenController extends Component implements IQuickOpenService
// merge history and default handler results
const
handlerResults
=
(
result
&&
result
.
entries
)
||
[];
this
.
mergeResults
(
quickOpenModel
,
handlerResults
,
resolvedHandler
.
getGroupLabel
());
this
.
mergeResults
(
quickOpenModel
,
handlerResults
,
resolvedHandler
.
getGroupLabel
()
||
undefined
);
}
});
});
}
private
mergeResults
(
quickOpenModel
:
QuickOpenModel
,
handlerResults
:
QuickOpenEntry
[],
groupLabel
:
string
):
void
{
private
mergeResults
(
quickOpenModel
:
QuickOpenModel
,
handlerResults
:
QuickOpenEntry
[],
groupLabel
:
string
|
undefined
):
void
{
// Remove results already showing by checking for a "resource" property
const
mapEntryToResource
=
this
.
mapEntriesToResource
(
quickOpenModel
);
...
...
@@ -526,7 +529,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
const
placeHolderLabel
=
(
typeof
canRun
===
'
string
'
)
?
canRun
:
nls
.
localize
(
'
canNotRunPlaceholder
'
,
"
This quick open handler can not be used in the current context
"
);
const
model
=
new
QuickOpenModel
([
new
PlaceholderQuickOpenEntry
(
placeHolderLabel
)],
this
.
actionProvider
);
this
.
showModel
(
model
,
resolvedHandler
.
getAutoFocus
(
value
,
{
model
,
quickNavigateConfiguration
:
this
.
quickOpenWidget
.
getQuickNavigateConfiguration
()
}),
resolvedHandler
.
getAriaLabel
());
this
.
showModel
(
model
,
resolvedHandler
.
getAutoFocus
(
value
,
{
model
,
quickNavigateConfiguration
:
this
.
quickOpenWidget
.
getQuickNavigateConfiguration
()
}),
resolvedHandler
.
getAriaLabel
()
||
undefined
);
return
Promise
.
resolve
(
undefined
);
}
...
...
@@ -547,9 +550,9 @@ export class QuickOpenController extends Component implements IQuickOpenService
if
(
!
token
.
isCancellationRequested
)
{
if
(
!
result
||
!
result
.
entries
.
length
)
{
const
model
=
new
QuickOpenModel
([
new
PlaceholderQuickOpenEntry
(
resolvedHandler
.
getEmptyLabel
(
value
))]);
this
.
showModel
(
model
,
resolvedHandler
.
getAutoFocus
(
value
,
{
model
,
quickNavigateConfiguration
:
this
.
quickOpenWidget
.
getQuickNavigateConfiguration
()
}),
resolvedHandler
.
getAriaLabel
());
this
.
showModel
(
model
,
resolvedHandler
.
getAutoFocus
(
value
,
{
model
,
quickNavigateConfiguration
:
this
.
quickOpenWidget
.
getQuickNavigateConfiguration
()
}),
resolvedHandler
.
getAriaLabel
()
||
undefined
);
}
else
{
this
.
showModel
(
result
,
resolvedHandler
.
getAutoFocus
(
value
,
{
model
:
result
,
quickNavigateConfiguration
:
this
.
quickOpenWidget
.
getQuickNavigateConfiguration
()
}),
resolvedHandler
.
getAriaLabel
());
this
.
showModel
(
result
,
resolvedHandler
.
getAutoFocus
(
value
,
{
model
:
result
,
quickNavigateConfiguration
:
this
.
quickOpenWidget
.
getQuickNavigateConfiguration
()
}),
resolvedHandler
.
getAriaLabel
()
||
undefined
);
}
}
});
...
...
@@ -570,15 +573,16 @@ export class QuickOpenController extends Component implements IQuickOpenService
}
private
clearModel
():
void
{
this
.
showModel
(
new
QuickOpenModel
(),
null
);
this
.
showModel
(
new
QuickOpenModel
(),
undefined
);
}
private
mapEntriesToResource
(
model
:
QuickOpenModel
):
{
[
resource
:
string
]:
QuickOpenEntry
;
}
{
const
entries
=
model
.
getEntries
();
const
mapEntryToPath
:
{
[
path
:
string
]:
QuickOpenEntry
;
}
=
{};
entries
.
forEach
((
entry
:
QuickOpenEntry
)
=>
{
if
(
entry
.
getResource
())
{
mapEntryToPath
[
entry
.
getResource
().
toString
()]
=
entry
;
const
resource
=
entry
.
getResource
();
if
(
resource
)
{
mapEntryToPath
[
resource
.
toString
()]
=
entry
;
}
});
...
...
@@ -655,7 +659,7 @@ class EditorHistoryHandler {
getResults
(
searchValue
?:
string
,
token
?:
CancellationToken
):
QuickOpenEntry
[]
{
// Massage search for scoring
const
query
=
prepareQuery
(
searchValue
);
const
query
=
prepareQuery
(
searchValue
||
''
);
// Just return all if we are not searching
const
history
=
this
.
historyService
.
getHistory
();
...
...
@@ -670,7 +674,7 @@ class EditorHistoryHandler {
// For now, only support to match on inputs that provide resource information
.
filter
(
input
=>
{
let
resource
:
URI
;
let
resource
:
URI
|
undefined
;
if
(
input
instanceof
EditorInput
)
{
resource
=
resourceForEditorHistory
(
input
,
this
.
fileService
);
}
else
{
...
...
@@ -690,7 +694,7 @@ class EditorHistoryHandler {
return
false
;
}
e
.
setHighlights
(
itemScore
.
labelMatch
,
itemScore
.
descriptionMatch
);
e
.
setHighlights
(
itemScore
.
labelMatch
||
[]
,
itemScore
.
descriptionMatch
);
return
true
;
})
...
...
@@ -707,8 +711,8 @@ class EditorHistoryItemAccessorClass extends QuickOpenItemAccessorClass {
super
();
}
getItemDescription
(
entry
:
QuickOpenEntry
):
string
{
return
this
.
allowMatchOnDescription
?
entry
.
getDescription
()
:
undefined
;
getItemDescription
(
entry
:
QuickOpenEntry
):
string
|
null
{
return
this
.
allowMatchOnDescription
?
entry
.
getDescription
()
:
null
;
}
}
...
...
@@ -721,9 +725,9 @@ export class EditorHistoryEntryGroup extends QuickOpenEntryGroup {
export
class
EditorHistoryEntry
extends
EditorQuickOpenEntry
{
private
input
:
IEditorInput
|
IResourceInput
;
private
resource
:
URI
;
private
label
:
string
;
private
description
:
string
;
private
resource
:
URI
|
undefined
;
private
label
:
string
|
null
;
private
description
:
string
|
null
;
private
dirty
:
boolean
;
constructor
(
...
...
@@ -749,7 +753,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
const
resourceInput
=
input
as
IResourceInput
;
this
.
resource
=
resourceInput
.
resource
;
this
.
label
=
resources
.
basenameOrAuthority
(
resourceInput
.
resource
);
this
.
description
=
labelService
.
getUriLabel
(
resources
.
dirname
(
this
.
resource
),
{
relative
:
true
});
this
.
description
=
labelService
.
getUriLabel
(
resources
.
dirname
(
this
.
resource
)
!
,
{
relative
:
true
});
this
.
dirty
=
this
.
resource
&&
this
.
textFileService
.
isDirty
(
this
.
resource
);
if
(
this
.
dirty
&&
this
.
textFileService
.
getAutoSaveMode
()
===
AutoSaveMode
.
AFTER_SHORT_DELAY
)
{
...
...
@@ -762,7 +766,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
return
this
.
dirty
?
'
dirty
'
:
''
;
}
getLabel
():
string
{
getLabel
():
string
|
null
{
return
this
.
label
;
}
...
...
@@ -776,12 +780,12 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
return
nls
.
localize
(
'
entryAriaLabel
'
,
"
{0}, recently opened
"
,
this
.
getLabel
());
}
getDescription
():
string
{
getDescription
():
string
|
null
{
return
this
.
description
;
}
getResource
():
URI
{
return
this
.
resource
;
getResource
():
URI
|
null
{
return
this
.
resource
||
null
;
}
getInput
():
IEditorInput
|
IResourceInput
{
...
...
@@ -806,7 +810,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
}
}
function
resourceForEditorHistory
(
input
:
EditorInput
,
fileService
:
IFileService
):
URI
{
function
resourceForEditorHistory
(
input
:
EditorInput
,
fileService
:
IFileService
):
URI
|
undefined
{
const
resource
=
input
?
input
.
getResource
()
:
undefined
;
// For the editor history we only prefer resources that are either untitled or
...
...
@@ -846,7 +850,7 @@ export class RemoveFromEditorHistoryAction extends Action {
return
<
IHistoryPickEntry
>
{
input
:
h
,
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
entry
.
getResource
()),
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
entry
.
getResource
()
||
undefined
),
label
:
entry
.
getLabel
(),
description
:
entry
.
getDescription
()
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录