Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
da546f5d
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,发现更多精彩内容 >>
提交
da546f5d
编写于
10月 11, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add null checks in filters and context keys
上级
0c403f82
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
44 addition
and
42 deletion
+44
-42
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+4
-2
src/vs/base/common/filters.ts
src/vs/base/common/filters.ts
+24
-24
src/vs/editor/common/editorContextKeys.ts
src/vs/editor/common/editorContextKeys.ts
+16
-16
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
da546f5d
...
...
@@ -36,6 +36,7 @@
"./vs/base/common/errors.ts"
,
"./vs/base/common/errorsWithActions.ts"
,
"./vs/base/common/event.ts"
,
"./vs/base/common/filters.ts"
,
"./vs/base/common/functional.ts"
,
"./vs/base/common/glob.ts"
,
"./vs/base/common/hash.ts"
,
...
...
@@ -105,6 +106,7 @@
"./vs/editor/common/model.ts"
,
"./vs/editor/common/model/editStack.ts"
,
"./vs/editor/common/model/intervalTree.ts"
,
"./vs/editor/common/editorContextKeys.ts"
,
"./vs/editor/common/model/mirrorTextModel.ts"
,
"./vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts"
,
"./vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.ts"
,
...
...
@@ -170,6 +172,7 @@
"./vs/platform/quickOpen/common/quickOpen.ts"
,
"./vs/platform/quickinput/common/quickInput.ts"
,
"./vs/platform/registry/common/platform.ts"
,
"./vs/platform/search/common/search.ts"
,
"./vs/platform/state/common/state.ts"
,
"./vs/platform/statusbar/common/statusbar.ts"
,
"./vs/platform/telemetry/common/telemetry.ts"
,
...
...
@@ -211,8 +214,7 @@
"./vs/workbench/services/panel/common/panelService.ts"
,
"./vs/workbench/services/search/node/search.ts"
,
"./vs/workbench/services/title/common/titleService.ts"
,
"./vs/workbench/test/electron-browser/api/mock.ts"
,
"vs/platform/search/common/search.ts"
"./vs/workbench/test/electron-browser/api/mock.ts"
],
"exclude"
:
[
"./typings/require-monaco.d.ts"
...
...
src/vs/base/common/filters.ts
浏览文件 @
da546f5d
...
...
@@ -9,7 +9,7 @@ import * as strings from 'vs/base/common/strings';
export
interface
IFilter
{
// Returns null if word doesn't match.
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[];
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
|
null
;
}
export
interface
IMatch
{
...
...
@@ -26,7 +26,7 @@ export interface IMatch {
* filter.
*/
export
function
or
(...
filter
:
IFilter
[]):
IFilter
{
return
function
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
{
return
function
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
|
null
{
for
(
let
i
=
0
,
len
=
filter
.
length
;
i
<
len
;
i
++
)
{
let
match
=
filter
[
i
](
word
,
wordToMatchAgainst
);
if
(
match
)
{
...
...
@@ -42,7 +42,7 @@ export function or(...filter: IFilter[]): IFilter {
export
const
matchesStrictPrefix
:
IFilter
=
_matchesPrefix
.
bind
(
undefined
,
false
);
export
const
matchesPrefix
:
IFilter
=
_matchesPrefix
.
bind
(
undefined
,
true
);
function
_matchesPrefix
(
ignoreCase
:
boolean
,
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
{
function
_matchesPrefix
(
ignoreCase
:
boolean
,
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
|
null
{
if
(
!
wordToMatchAgainst
||
wordToMatchAgainst
.
length
<
word
.
length
)
{
return
null
;
}
...
...
@@ -63,7 +63,7 @@ function _matchesPrefix(ignoreCase: boolean, word: string, wordToMatchAgainst: s
// Contiguous Substring
export
function
matchesContiguousSubString
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
{
export
function
matchesContiguousSubString
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
|
null
{
let
index
=
wordToMatchAgainst
.
toLowerCase
().
indexOf
(
word
.
toLowerCase
());
if
(
index
===
-
1
)
{
return
null
;
...
...
@@ -74,18 +74,18 @@ export function matchesContiguousSubString(word: string, wordToMatchAgainst: str
// Substring
export
function
matchesSubString
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
{
export
function
matchesSubString
(
word
:
string
,
wordToMatchAgainst
:
string
):
IMatch
[]
|
null
{
return
_matchesSubString
(
word
.
toLowerCase
(),
wordToMatchAgainst
.
toLowerCase
(),
0
,
0
);
}
function
_matchesSubString
(
word
:
string
,
wordToMatchAgainst
:
string
,
i
:
number
,
j
:
number
):
IMatch
[]
{
function
_matchesSubString
(
word
:
string
,
wordToMatchAgainst
:
string
,
i
:
number
,
j
:
number
):
IMatch
[]
|
null
{
if
(
i
===
word
.
length
)
{
return
[];
}
else
if
(
j
===
wordToMatchAgainst
.
length
)
{
return
null
;
}
else
{
if
(
word
[
i
]
===
wordToMatchAgainst
[
j
])
{
let
result
:
IMatch
[]
=
null
;
let
result
:
IMatch
[]
|
null
=
null
;
if
(
result
=
_matchesSubString
(
word
,
wordToMatchAgainst
,
i
+
1
,
j
+
1
))
{
return
join
({
start
:
j
,
end
:
j
+
1
},
result
);
}
...
...
@@ -144,7 +144,7 @@ function nextAnchor(camelCaseWord: string, start: number): number {
return
camelCaseWord
.
length
;
}
function
_matchesCamelCase
(
word
:
string
,
camelCaseWord
:
string
,
i
:
number
,
j
:
number
):
IMatch
[]
{
function
_matchesCamelCase
(
word
:
string
,
camelCaseWord
:
string
,
i
:
number
,
j
:
number
):
IMatch
[]
|
null
{
if
(
i
===
word
.
length
)
{
return
[];
}
else
if
(
j
===
camelCaseWord
.
length
)
{
...
...
@@ -152,7 +152,7 @@ function _matchesCamelCase(word: string, camelCaseWord: string, i: number, j: nu
}
else
if
(
word
[
i
]
!==
camelCaseWord
[
j
].
toLowerCase
())
{
return
null
;
}
else
{
let
result
:
IMatch
[]
=
null
;
let
result
:
IMatch
[]
|
null
=
null
;
let
nextUpperIndex
=
j
+
1
;
result
=
_matchesCamelCase
(
word
,
camelCaseWord
,
i
+
1
,
j
+
1
);
while
(
!
result
&&
(
nextUpperIndex
=
nextAnchor
(
camelCaseWord
,
nextUpperIndex
))
<
camelCaseWord
.
length
)
{
...
...
@@ -222,7 +222,7 @@ function isCamelCasePattern(word: string): boolean {
}
}
export
function
matchesCamelCase
(
word
:
string
,
camelCaseWord
:
string
):
IMatch
[]
{
export
function
matchesCamelCase
(
word
:
string
,
camelCaseWord
:
string
):
IMatch
[]
|
null
{
if
(
!
camelCaseWord
)
{
return
null
;
}
...
...
@@ -251,7 +251,7 @@ export function matchesCamelCase(word: string, camelCaseWord: string): IMatch[]
camelCaseWord
=
camelCaseWord
.
toLowerCase
();
}
let
result
:
IMatch
[]
=
null
;
let
result
:
IMatch
[]
|
null
=
null
;
let
i
=
0
;
word
=
word
.
toLowerCase
();
...
...
@@ -267,12 +267,12 @@ export function matchesCamelCase(word: string, camelCaseWord: string): IMatch[]
// Otherwise also matches sub string of the word with beginnings of the words in the target. E.g. "gp" or "g p" will match "Git: Pull"
// Useful in cases where the target is words (e.g. command labels)
export
function
matchesWords
(
word
:
string
,
target
:
string
,
contiguous
:
boolean
=
false
):
IMatch
[]
{
export
function
matchesWords
(
word
:
string
,
target
:
string
,
contiguous
:
boolean
=
false
):
IMatch
[]
|
null
{
if
(
!
target
||
target
.
length
===
0
)
{
return
null
;
}
let
result
:
IMatch
[]
=
null
;
let
result
:
IMatch
[]
|
null
=
null
;
let
i
=
0
;
word
=
word
.
toLowerCase
();
...
...
@@ -284,7 +284,7 @@ export function matchesWords(word: string, target: string, contiguous: boolean =
return
result
;
}
function
_matchesWords
(
word
:
string
,
target
:
string
,
i
:
number
,
j
:
number
,
contiguous
:
boolean
):
IMatch
[]
{
function
_matchesWords
(
word
:
string
,
target
:
string
,
i
:
number
,
j
:
number
,
contiguous
:
boolean
):
IMatch
[]
|
null
{
if
(
i
===
word
.
length
)
{
return
[];
}
else
if
(
j
===
target
.
length
)
{
...
...
@@ -292,7 +292,7 @@ function _matchesWords(word: string, target: string, i: number, j: number, conti
}
else
if
(
word
[
i
]
!==
target
[
j
])
{
return
null
;
}
else
{
let
result
:
IMatch
[]
=
null
;
let
result
:
IMatch
[]
|
null
=
null
;
let
nextWordIndex
=
j
+
1
;
result
=
_matchesWords
(
word
,
target
,
i
+
1
,
j
+
1
,
contiguous
);
if
(
!
contiguous
)
{
...
...
@@ -321,7 +321,7 @@ export const fuzzyContiguousFilter = or(matchesPrefix, matchesCamelCase, matches
const
fuzzySeparateFilter
=
or
(
matchesPrefix
,
matchesCamelCase
,
matchesSubString
);
const
fuzzyRegExpCache
=
new
LRUCache
<
string
,
RegExp
>
(
10000
);
// bounded to 10000 elements
export
function
matchesFuzzy
(
word
:
string
,
wordToMatchAgainst
:
string
,
enableSeparateSubstringMatching
=
false
):
IMatch
[]
{
export
function
matchesFuzzy
(
word
:
string
,
wordToMatchAgainst
:
string
,
enableSeparateSubstringMatching
=
false
):
IMatch
[]
|
null
{
if
(
typeof
word
!==
'
string
'
||
typeof
wordToMatchAgainst
!==
'
string
'
)
{
return
null
;
// return early for invalid input
}
...
...
@@ -334,7 +334,7 @@ export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSep
}
// RegExp Filter
let
match
:
RegExpExecArray
=
regexp
.
exec
(
wordToMatchAgainst
);
let
match
=
regexp
.
exec
(
wordToMatchAgainst
);
if
(
match
)
{
return
[{
start
:
match
.
index
,
end
:
match
.
index
+
match
[
0
].
length
}];
}
...
...
@@ -372,7 +372,7 @@ export function createMatches(offsetOrScore: number[] | FuzzyScore): IMatch[] {
}
else
{
offsets
=
offsetOrScore
as
number
[];
}
let
last
:
IMatch
;
let
last
:
IMatch
|
undefined
;
for
(
const
pos
of
offsets
)
{
if
(
last
&&
last
.
end
===
pos
)
{
last
.
end
+=
1
;
...
...
@@ -466,7 +466,7 @@ export interface FuzzyScorer {
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
;
}
export
function
fuzzyScore
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
{
export
function
fuzzyScore
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
|
undefined
{
const
patternLen
=
pattern
.
length
>
100
?
100
:
pattern
.
length
;
const
wordLen
=
word
.
length
>
100
?
100
:
word
.
length
;
...
...
@@ -711,16 +711,16 @@ class LazyArray {
//#region --- graceful ---
export
function
fuzzyScoreGracefulAggressive
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
{
export
function
fuzzyScoreGracefulAggressive
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
|
undefined
{
return
fuzzyScoreWithPermutations
(
pattern
,
lowPattern
,
patternPos
,
word
,
lowWord
,
wordPos
,
true
,
firstMatchCanBeWeak
);
}
export
function
fuzzyScoreGraceful
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
{
export
function
fuzzyScoreGraceful
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
|
undefined
{
return
fuzzyScoreWithPermutations
(
pattern
,
lowPattern
,
patternPos
,
word
,
lowWord
,
wordPos
,
false
,
firstMatchCanBeWeak
);
}
function
fuzzyScoreWithPermutations
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
aggressive
:
boolean
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
{
let
top
:
[
number
,
number
[]]
=
fuzzyScore
(
pattern
,
lowPattern
,
patternPos
,
word
,
lowWord
,
wordPos
,
firstMatchCanBeWeak
);
function
fuzzyScoreWithPermutations
(
pattern
:
string
,
lowPattern
:
string
,
patternPos
:
number
,
word
:
string
,
lowWord
:
string
,
wordPos
:
number
,
aggressive
:
boolean
,
firstMatchCanBeWeak
:
boolean
):
FuzzyScore
|
undefined
{
let
top
=
fuzzyScore
(
pattern
,
lowPattern
,
patternPos
,
word
,
lowWord
,
wordPos
,
firstMatchCanBeWeak
);
if
(
top
&&
!
aggressive
)
{
// when using the original pattern yield a result we`
...
...
@@ -752,7 +752,7 @@ function fuzzyScoreWithPermutations(pattern: string, lowPattern: string, pattern
return
top
;
}
function
nextTypoPermutation
(
pattern
:
string
,
patternPos
:
number
):
string
{
function
nextTypoPermutation
(
pattern
:
string
,
patternPos
:
number
):
string
|
undefined
{
if
(
patternPos
+
1
>=
pattern
.
length
)
{
return
undefined
;
...
...
src/vs/editor/common/editorContextKeys.ts
浏览文件 @
da546f5d
...
...
@@ -28,24 +28,24 @@ export namespace EditorContextKeys {
export
const
hasSingleSelection
:
ContextKeyExpr
=
hasMultipleSelections
.
toNegated
();
export
const
tabMovesFocus
=
new
RawContextKey
<
boolean
>
(
'
editorTabMovesFocus
'
,
false
);
export
const
tabDoesNotMoveFocus
:
ContextKeyExpr
=
tabMovesFocus
.
toNegated
();
export
const
isInEmbeddedEditor
=
new
RawContextKey
<
boolean
>
(
'
isInEmbeddedEditor
'
,
undefined
);
export
const
isInEmbeddedEditor
=
new
RawContextKey
<
boolean
>
(
'
isInEmbeddedEditor
'
,
false
);
export
const
canUndo
=
new
RawContextKey
<
boolean
>
(
'
canUndo
'
,
false
);
export
const
canRedo
=
new
RawContextKey
<
boolean
>
(
'
canRedo
'
,
false
);
// -- mode context keys
export
const
languageId
=
new
RawContextKey
<
string
>
(
'
editorLangId
'
,
undefined
);
export
const
hasCompletionItemProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCompletionItemProvider
'
,
undefined
);
export
const
hasCodeActionsProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCodeActionsProvider
'
,
undefined
);
export
const
hasCodeLensProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCodeLensProvider
'
,
undefined
);
export
const
hasDefinitionProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDefinitionProvider
'
,
undefined
);
export
const
hasImplementationProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasImplementationProvider
'
,
undefined
);
export
const
hasTypeDefinitionProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasTypeDefinitionProvider
'
,
undefined
);
export
const
hasHoverProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasHoverProvider
'
,
undefined
);
export
const
hasDocumentHighlightProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentHighlightProvider
'
,
undefined
);
export
const
hasDocumentSymbolProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentSymbolProvider
'
,
undefined
);
export
const
hasReferenceProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasReferenceProvider
'
,
undefined
);
export
const
hasRenameProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasRenameProvider
'
,
undefined
);
export
const
hasDocumentFormattingProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentFormattingProvider
'
,
undefined
);
export
const
hasDocumentSelectionFormattingProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentSelectionFormattingProvider
'
,
undefined
);
export
const
hasSignatureHelpProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasSignatureHelpProvider
'
,
undefined
);
export
const
languageId
=
new
RawContextKey
<
string
>
(
'
editorLangId
'
,
''
);
export
const
hasCompletionItemProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCompletionItemProvider
'
,
false
);
export
const
hasCodeActionsProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCodeActionsProvider
'
,
false
);
export
const
hasCodeLensProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCodeLensProvider
'
,
false
);
export
const
hasDefinitionProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDefinitionProvider
'
,
false
);
export
const
hasImplementationProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasImplementationProvider
'
,
false
);
export
const
hasTypeDefinitionProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasTypeDefinitionProvider
'
,
false
);
export
const
hasHoverProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasHoverProvider
'
,
false
);
export
const
hasDocumentHighlightProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentHighlightProvider
'
,
false
);
export
const
hasDocumentSymbolProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentSymbolProvider
'
,
false
);
export
const
hasReferenceProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasReferenceProvider
'
,
false
);
export
const
hasRenameProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasRenameProvider
'
,
false
);
export
const
hasDocumentFormattingProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentFormattingProvider
'
,
false
);
export
const
hasDocumentSelectionFormattingProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDocumentSelectionFormattingProvider
'
,
false
);
export
const
hasSignatureHelpProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasSignatureHelpProvider
'
,
false
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录