Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
8c0fdc2b
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8c0fdc2b
编写于
3月 19, 2019
作者:
U
Ubuntu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #69687 - strict null check search
上级
30b2c307
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
48 addition
and
40 deletion
+48
-40
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+1
-0
src/vs/workbench/contrib/search/browser/search.contribution.ts
...s/workbench/contrib/search/browser/search.contribution.ts
+7
-5
src/vs/workbench/contrib/search/browser/searchActions.ts
src/vs/workbench/contrib/search/browser/searchActions.ts
+20
-11
src/vs/workbench/contrib/search/browser/searchPanel.ts
src/vs/workbench/contrib/search/browser/searchPanel.ts
+1
-1
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+12
-14
src/vs/workbench/contrib/search/browser/searchViewlet.ts
src/vs/workbench/contrib/search/browser/searchViewlet.ts
+2
-2
src/vs/workbench/contrib/search/browser/searchWidget.ts
src/vs/workbench/contrib/search/browser/searchWidget.ts
+4
-6
src/vs/workbench/contrib/search/common/searchModel.ts
src/vs/workbench/contrib/search/common/searchModel.ts
+1
-1
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
8c0fdc2b
...
...
@@ -36,6 +36,7 @@
"./vs/workbench/contrib/webview/**/*.ts"
,
"./vs/workbench/contrib/preferences/common/**/*.ts"
,
"./vs/workbench/contrib/preferences/**/settings*.ts"
,
"./vs/workbench/contrib/search/**/*.ts"
,
"./vs/workbench/contrib/terminal/**/*"
],
"files"
:
[
...
...
src/vs/workbench/contrib/search/browser/search.contribution.ts
浏览文件 @
8c0fdc2b
...
...
@@ -365,15 +365,15 @@ const searchInFolderCommand: ICommandHandler = (accessor, resource?: URI) => {
const
panelService
=
accessor
.
get
(
IPanelService
);
const
fileService
=
accessor
.
get
(
IFileService
);
const
configurationService
=
accessor
.
get
(
IConfigurationService
);
const
resources
=
getMultiSelectedResources
(
resource
,
listService
,
accessor
.
get
(
IEditorService
));
const
resources
=
resource
&&
getMultiSelectedResources
(
resource
,
listService
,
accessor
.
get
(
IEditorService
));
return
openSearchView
(
viewletService
,
panelService
,
configurationService
,
true
).
then
(
searchView
=>
{
if
(
resources
&&
resources
.
length
)
{
if
(
resources
&&
resources
.
length
&&
searchView
)
{
return
fileService
.
resolveFiles
(
resources
.
map
(
resource
=>
({
resource
}))).
then
(
results
=>
{
const
folders
:
URI
[]
=
[];
results
.
forEach
(
result
=>
{
if
(
result
.
success
)
{
if
(
result
.
success
&&
result
.
stat
)
{
folders
.
push
(
result
.
stat
.
isDirectory
?
result
.
stat
.
resource
:
dirname
(
result
.
stat
.
resource
));
}
});
...
...
@@ -414,7 +414,9 @@ CommandsRegistry.registerCommand({
id
:
FIND_IN_WORKSPACE_ID
,
handler
:
(
accessor
)
=>
{
return
openSearchView
(
accessor
.
get
(
IViewletService
),
accessor
.
get
(
IPanelService
),
accessor
.
get
(
IConfigurationService
),
true
).
then
(
searchView
=>
{
searchView
.
searchInFolders
(
null
);
if
(
searchView
)
{
searchView
.
searchInFolders
();
}
});
}
});
...
...
@@ -456,7 +458,7 @@ class ShowAllSymbolsAction extends Action {
run
(
context
?:
any
):
Promise
<
void
>
{
let
prefix
=
ShowAllSymbolsAction
.
ALL_SYMBOLS_PREFIX
;
let
inputSelection
:
{
start
:
number
;
end
:
number
;
}
=
undefined
;
let
inputSelection
:
{
start
:
number
;
end
:
number
;
}
|
undefined
=
undefined
;
const
editor
=
this
.
editorService
.
getFocusedCodeEditor
();
const
word
=
editor
&&
getSelectionSearchString
(
editor
);
if
(
word
)
{
...
...
src/vs/workbench/contrib/search/browser/searchActions.ts
浏览文件 @
8c0fdc2b
...
...
@@ -52,14 +52,15 @@ export function appendKeyBindingLabel(label: string, inputKeyBinding: number | R
}
}
export
function
openSearchView
(
viewletService
:
IViewletService
,
panelService
:
IPanelService
,
configurationService
:
IConfigurationService
,
focus
?:
boolean
):
Promise
<
SearchView
>
{
export
function
openSearchView
(
viewletService
:
IViewletService
,
panelService
:
IPanelService
,
configurationService
:
IConfigurationService
,
focus
?:
boolean
):
Promise
<
SearchView
|
undefined
>
{
if
(
configurationService
.
getValue
<
ISearchConfiguration
>
().
search
.
location
===
'
panel
'
)
{
return
Promise
.
resolve
((
panelService
.
openPanel
(
PANEL_ID
,
focus
)
as
SearchPanel
).
getSearchView
());
}
return
viewletService
.
openViewlet
(
VIEWLET_ID
,
focus
).
then
(
viewlet
=>
(
viewlet
as
SearchViewlet
).
getSearchView
());
}
export
function
getSearchView
(
viewletService
:
IViewletService
,
panelService
:
IPanelService
):
SearchView
|
null
{
export
function
getSearchView
(
viewletService
:
IViewletService
,
panelService
:
IPanelService
):
SearchView
|
undefined
{
const
activeViewlet
=
viewletService
.
getActiveViewlet
();
if
(
activeViewlet
&&
activeViewlet
.
getId
()
===
VIEWLET_ID
)
{
return
(
activeViewlet
as
SearchViewlet
).
getSearchView
();
...
...
@@ -70,7 +71,7 @@ export function getSearchView(viewletService: IViewletService, panelService: IPa
return
(
activePanel
as
SearchPanel
).
getSearchView
();
}
return
null
;
return
undefined
;
}
function
doAppendKeyBindingLabel
(
label
:
string
,
keyBinding
:
ResolvedKeybinding
|
undefined
):
string
{
...
...
@@ -149,11 +150,13 @@ export abstract class FindOrReplaceInFilesAction extends Action {
run
():
Promise
<
any
>
{
return
openSearchView
(
this
.
viewletService
,
this
.
panelService
,
this
.
configurationService
,
false
).
then
(
openedView
=>
{
const
searchAndReplaceWidget
=
openedView
.
searchAndReplaceWidget
;
searchAndReplaceWidget
.
toggleReplace
(
this
.
expandSearchReplaceWidget
);
if
(
openedView
)
{
const
searchAndReplaceWidget
=
openedView
.
searchAndReplaceWidget
;
searchAndReplaceWidget
.
toggleReplace
(
this
.
expandSearchReplaceWidget
);
const
updatedText
=
openedView
.
updateTextFromSelection
(
!
this
.
expandSearchReplaceWidget
);
openedView
.
searchAndReplaceWidget
.
focus
(
undefined
,
updatedText
,
updatedText
);
const
updatedText
=
openedView
.
updateTextFromSelection
(
!
this
.
expandSearchReplaceWidget
);
openedView
.
searchAndReplaceWidget
.
focus
(
undefined
,
updatedText
,
updatedText
);
}
});
}
}
...
...
@@ -240,7 +243,7 @@ export class RefreshAction extends Action {
static
readonly
ID
:
string
=
'
search.action.refreshSearchResults
'
;
static
LABEL
:
string
=
nls
.
localize
(
'
RefreshAction.label
'
,
"
Refresh
"
);
private
searchView
:
SearchView
|
null
;
private
searchView
:
SearchView
|
undefined
;
constructor
(
id
:
string
,
label
:
string
,
@
IViewletService
private
readonly
viewletService
:
IViewletService
,
...
...
@@ -394,7 +397,9 @@ export class FocusNextSearchResultAction extends Action {
run
():
Promise
<
any
>
{
return
openSearchView
(
this
.
viewletService
,
this
.
panelService
,
this
.
configurationService
).
then
(
searchView
=>
{
searchView
.
selectNextMatch
();
if
(
searchView
)
{
searchView
.
selectNextMatch
();
}
});
}
}
...
...
@@ -413,7 +418,9 @@ export class FocusPreviousSearchResultAction extends Action {
run
():
Promise
<
any
>
{
return
openSearchView
(
this
.
viewletService
,
this
.
panelService
,
this
.
configurationService
).
then
(
searchView
=>
{
searchView
.
selectPreviousMatch
();
if
(
searchView
)
{
searchView
.
selectPreviousMatch
();
}
});
}
}
...
...
@@ -771,6 +778,8 @@ export const focusSearchListCommand: ICommandHandler = accessor => {
const
panelService
=
accessor
.
get
(
IPanelService
);
const
configurationService
=
accessor
.
get
(
IConfigurationService
);
openSearchView
(
viewletService
,
panelService
,
configurationService
).
then
(
searchView
=>
{
searchView
.
moveFocusToResults
();
if
(
searchView
)
{
searchView
.
moveFocusToResults
();
}
});
};
src/vs/workbench/contrib/search/browser/searchPanel.ts
浏览文件 @
8c0fdc2b
...
...
@@ -64,7 +64,7 @@ export class SearchPanel extends Panel {
super
.
saveState
();
}
getSearchView
():
SearchView
|
null
{
getSearchView
():
SearchView
{
return
this
.
searchView
;
}
}
\ No newline at end of file
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
8c0fdc2b
...
...
@@ -115,13 +115,13 @@ export class SearchView extends ViewletPanel {
private
inputPatternIncludes
:
PatternInputWidget
;
private
resultsElement
:
HTMLElement
;
private
currentSelectedFileMatch
:
FileMatch
;
private
currentSelectedFileMatch
:
FileMatch
|
undefined
;
private
readonly
selectCurrentMatchEmitter
:
Emitter
<
string
|
undefined
>
;
private
delayedRefresh
:
Delayer
<
void
>
;
private
changedWhileHidden
:
boolean
;
private
searchWithoutFolderMessageElement
:
HTMLElement
;
private
searchWithoutFolderMessageElement
:
HTMLElement
|
undefined
;
private
currentSearchQ
=
Promise
.
resolve
();
...
...
@@ -474,7 +474,7 @@ export class SearchView extends ViewletPanel {
});
}
private
createFolderIterator
(
folderMatch
:
FolderMatch
,
collapseResults
:
ISearchConfigurationProperties
[
'
collapseResults
'
]):
Iterator
<
ITreeElement
<
RenderableMatch
>>
{
private
createFolderIterator
(
folderMatch
:
Base
FolderMatch
,
collapseResults
:
ISearchConfigurationProperties
[
'
collapseResults
'
]):
Iterator
<
ITreeElement
<
RenderableMatch
>>
{
const
filesIt
=
Iterator
.
fromArray
(
folderMatch
.
matches
()
.
sort
(
searchMatchComparer
));
...
...
@@ -797,7 +797,7 @@ export class SearchView extends ViewletPanel {
updateTextFromSelection
(
allowUnselectedWord
=
true
):
boolean
{
let
updatedText
=
false
;
const
seedSearchStringFromSelection
=
this
.
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
).
find
.
seedSearchStringFromSelection
;
const
seedSearchStringFromSelection
=
this
.
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
).
find
!
.
seedSearchStringFromSelection
;
if
(
seedSearchStringFromSelection
)
{
let
selectedText
=
this
.
getSearchTextFromEditor
(
allowUnselectedWord
);
if
(
selectedText
)
{
...
...
@@ -1074,7 +1074,7 @@ export class SearchView extends ViewletPanel {
}
}
searchInFolders
(
resources
:
URI
[]):
void
{
searchInFolders
(
resources
?
:
URI
[]):
void
{
const
folderPaths
:
string
[]
=
[];
const
workspace
=
this
.
contextService
.
getWorkspace
();
...
...
@@ -1338,7 +1338,7 @@ export class SearchView extends ViewletPanel {
const
onError
=
(
e
:
any
)
=>
{
if
(
errors
.
isPromiseCanceledError
(
e
))
{
return
onComplete
(
null
);
return
onComplete
(
undefined
);
}
else
{
this
.
searching
=
false
;
this
.
updateActions
();
...
...
@@ -1422,7 +1422,7 @@ export class SearchView extends ViewletPanel {
this
.
openSettings
(
'
.exclude
'
);
}
private
openSettings
(
query
:
string
):
Promise
<
IEditor
>
{
private
openSettings
(
query
:
string
):
Promise
<
IEditor
|
null
>
{
const
options
:
ISettingsEditorOptions
=
{
query
};
return
this
.
contextService
.
getWorkbenchState
()
!==
WorkbenchState
.
EMPTY
?
this
.
preferencesService
.
openWorkspaceSettings
(
undefined
,
options
)
:
...
...
@@ -1480,7 +1480,7 @@ export class SearchView extends ViewletPanel {
const
actionClass
=
env
.
isMacintosh
?
OpenFileFolderAction
:
OpenFolderAction
;
const
action
=
this
.
instantiationService
.
createInstance
<
string
,
string
,
IAction
>
(
actionClass
,
actionClass
.
ID
,
actionClass
.
LABEL
);
this
.
actionRunner
.
run
(
action
).
then
(()
=>
{
this
.
actionRunner
!
.
run
(
action
).
then
(()
=>
{
action
.
dispose
();
},
err
=>
{
action
.
dispose
();
...
...
@@ -1499,7 +1499,7 @@ export class SearchView extends ViewletPanel {
// this.replaceService.disposeAllReplacePreviews();
dom
.
hide
(
this
.
messagesElement
);
dom
.
show
(
this
.
resultsElement
);
this
.
currentSelectedFileMatch
=
null
;
this
.
currentSelectedFileMatch
=
undefined
;
}
private
onFocus
(
lineMatch
:
any
,
preserveFocus
?:
boolean
,
sideBySide
?:
boolean
,
pinned
?:
boolean
):
Promise
<
any
>
{
...
...
@@ -1514,7 +1514,7 @@ export class SearchView extends ViewletPanel {
this
.
open
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
);
}
open
(
element
:
FileMatchOrMatch
,
preserveFocus
?:
boolean
,
sideBySide
?:
boolean
,
pinned
?:
boolean
):
Promise
<
any
>
{
open
(
element
:
FileMatchOrMatch
,
preserveFocus
?:
boolean
,
sideBySide
?:
boolean
,
pinned
?:
boolean
):
Promise
<
void
>
{
const
selection
=
this
.
getSelectionFrom
(
element
);
const
resource
=
element
instanceof
Match
?
element
.
parent
().
resource
()
:
(
<
FileMatch
>
element
).
resource
();
return
this
.
editorService
.
openEditor
({
...
...
@@ -1528,7 +1528,7 @@ export class SearchView extends ViewletPanel {
},
sideBySide
?
SIDE_GROUP
:
ACTIVE_GROUP
).
then
(
editor
=>
{
if
(
editor
&&
element
instanceof
Match
&&
preserveFocus
)
{
this
.
viewModel
.
searchResult
.
rangeHighlightDecorations
.
highlightRange
(
(
<
ICodeEditor
>
editor
.
getControl
()).
getModel
(),
(
<
ICodeEditor
>
editor
.
getControl
()).
getModel
()
!
,
element
.
range
()
);
}
else
{
...
...
@@ -1536,9 +1536,7 @@ export class SearchView extends ViewletPanel {
}
if
(
editor
)
{
return
this
.
editorGroupsService
.
activateGroup
(
editor
.
group
);
}
else
{
return
Promise
.
resolve
(
null
);
this
.
editorGroupsService
.
activateGroup
(
editor
.
group
!
);
}
},
errors
.
onUnexpectedError
);
}
...
...
src/vs/workbench/contrib/search/browser/searchViewlet.ts
浏览文件 @
8c0fdc2b
...
...
@@ -38,8 +38,8 @@ export class SearchViewlet extends ViewContainerViewlet {
return
Registry
.
as
<
ViewletRegistry
>
(
Extensions
.
Viewlets
).
getViewlet
(
this
.
getId
()).
name
;
}
getSearchView
():
SearchView
|
null
{
getSearchView
():
SearchView
|
undefined
{
const
view
=
super
.
getView
(
VIEW_ID
);
return
view
?
view
as
SearchView
:
null
;
return
view
?
view
as
SearchView
:
undefined
;
}
}
\ No newline at end of file
src/vs/workbench/contrib/search/browser/searchWidget.ts
浏览文件 @
8c0fdc2b
...
...
@@ -56,7 +56,7 @@ class ReplaceAllAction extends Action {
return
ReplaceAllAction
.
fgInstance
;
}
private
_searchWidget
:
SearchWidget
|
null
=
null
;
private
_searchWidget
:
SearchWidget
;
constructor
()
{
super
(
ReplaceAllAction
.
ID
,
''
,
'
action-replace-all
'
,
false
);
...
...
@@ -113,8 +113,8 @@ export class SearchWidget extends Widget {
private
_onReplaceStateChange
=
this
.
_register
(
new
Emitter
<
boolean
>
());
readonly
onReplaceStateChange
:
Event
<
boolean
>
=
this
.
_onReplaceStateChange
.
event
;
private
_onReplaceValueChanged
=
this
.
_register
(
new
Emitter
<
string
|
undefine
d
>
());
readonly
onReplaceValueChanged
:
Event
<
string
>
=
this
.
_onReplaceValueChanged
.
event
;
private
_onReplaceValueChanged
=
this
.
_register
(
new
Emitter
<
voi
d
>
());
readonly
onReplaceValueChanged
:
Event
<
void
>
=
this
.
_onReplaceValueChanged
.
event
;
private
_onReplaceAll
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onReplaceAll
:
Event
<
void
>
=
this
.
_onReplaceAll
.
event
;
...
...
@@ -343,7 +343,7 @@ export class SearchWidget extends Widget {
this
.
_register
(
attachInputBoxStyler
(
this
.
replaceInput
,
this
.
themeService
));
this
.
onkeydown
(
this
.
replaceInput
.
inputElement
,
(
keyboardEvent
)
=>
this
.
onReplaceInputKeyDown
(
keyboardEvent
));
this
.
replaceInput
.
value
=
options
.
replaceValue
||
''
;
this
.
_register
(
this
.
replaceInput
.
onDidChange
(()
=>
this
.
_onReplaceValueChanged
.
fire
(
undefined
)));
this
.
_register
(
this
.
replaceInput
.
onDidChange
(()
=>
this
.
_onReplaceValueChanged
.
fire
()));
this
.
_register
(
this
.
replaceInput
.
onDidHeightChange
(()
=>
this
.
_onDidHeightChange
.
fire
()));
this
.
replaceAllAction
=
ReplaceAllAction
.
INSTANCE
;
...
...
@@ -532,8 +532,6 @@ export class SearchWidget extends Widget {
dispose
():
void
{
this
.
setReplaceAllActionState
(
false
);
this
.
replaceAllAction
.
searchWidget
=
null
;
this
.
replaceActionBar
=
null
;
super
.
dispose
();
}
...
...
src/vs/workbench/contrib/search/common/searchModel.ts
浏览文件 @
8c0fdc2b
...
...
@@ -389,7 +389,7 @@ export class FileMatch extends Disposable {
}
export
interface
IChangeEvent
{
elements
:
(
FileMatch
|
FolderMatch
|
SearchResult
|
null
)[];
elements
:
(
FileMatch
|
FolderMatch
|
SearchResult
)[];
added
?:
boolean
;
removed
?:
boolean
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录