Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
60c316f5
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,发现更多精彩内容 >>
提交
60c316f5
编写于
3月 21, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace `|| undefined` with `withNullAsUndefined`
This is more explicit and correctly handles some edge cases
上级
31f4f3da
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
26 addition
and
18 deletion
+26
-18
src/vs/editor/contrib/snippet/snippetSession.ts
src/vs/editor/contrib/snippet/snippetSession.ts
+2
-1
src/vs/workbench/browser/parts/editor/titleControl.ts
src/vs/workbench/browser/parts/editor/titleControl.ts
+2
-1
src/vs/workbench/browser/parts/quickinput/quickInputList.ts
src/vs/workbench/browser/parts/quickinput/quickInputList.ts
+4
-3
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
.../workbench/browser/parts/quickopen/quickOpenController.ts
+1
-1
src/vs/workbench/browser/quickopen.ts
src/vs/workbench/browser/quickopen.ts
+1
-1
src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts
...kbench/contrib/files/browser/editors/fileEditorTracker.ts
+2
-1
src/vs/workbench/contrib/preferences/electron-browser/settingsEditor2.ts
...h/contrib/preferences/electron-browser/settingsEditor2.ts
+2
-2
src/vs/workbench/contrib/search/common/searchModel.ts
src/vs/workbench/contrib/search/common/searchModel.ts
+2
-1
src/vs/workbench/contrib/terminal/browser/terminalActions.ts
src/vs/workbench/contrib/terminal/browser/terminalActions.ts
+2
-1
src/vs/workbench/services/configuration/common/configurationEditingService.ts
...vices/configuration/common/configurationEditingService.ts
+4
-4
src/vs/workbench/services/extensions/electron-browser/extensionHostProfiler.ts
...ices/extensions/electron-browser/extensionHostProfiler.ts
+2
-1
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
...test/electron-browser/api/extHostLanguageFeatures.test.ts
+2
-1
未找到文件。
src/vs/editor/contrib/snippet/snippetSession.ts
浏览文件 @
60c316f5
...
...
@@ -21,6 +21,7 @@ import { Choice, Placeholder, SnippetParser, Text, TextmateSnippet } from './sni
import
{
ClipboardBasedVariableResolver
,
CompositeSnippetVariableResolver
,
ModelBasedVariableResolver
,
SelectionBasedVariableResolver
,
TimeBasedVariableResolver
,
CommentBasedVariableResolver
,
WorkspaceBasedVariableResolver
}
from
'
./snippetVariables
'
;
import
{
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
*
as
colors
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
registerThemingParticipant
((
theme
,
collector
)
=>
{
...
...
@@ -281,7 +282,7 @@ export class OneSnippet {
let
result
:
Range
|
undefined
;
const
model
=
this
.
_editor
.
getModel
();
this
.
_placeholderDecorations
.
forEach
((
decorationId
)
=>
{
const
placeholderRange
=
model
.
getDecorationRange
(
decorationId
)
||
undefined
;
const
placeholderRange
=
withNullAsUndefined
(
model
.
getDecorationRange
(
decorationId
))
;
if
(
!
result
)
{
result
=
placeholderRange
;
}
else
{
...
...
src/vs/workbench/browser/parts/editor/titleControl.ts
浏览文件 @
60c316f5
...
...
@@ -39,6 +39,7 @@ import { Themable } from 'vs/workbench/common/theme';
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
AnchorAlignment
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
interface
IToolbarActions
{
primary
:
IAction
[];
...
...
@@ -321,7 +322,7 @@ export abstract class TitleControl extends Themable {
protected
getKeybindingLabel
(
action
:
IAction
):
string
|
undefined
{
const
keybinding
=
this
.
getKeybinding
(
action
);
return
keybinding
?
keybinding
.
getLabel
()
||
undefined
:
undefined
;
return
keybinding
?
withNullAsUndefined
(
keybinding
.
getLabel
())
:
undefined
;
}
abstract
openEditor
(
editor
:
IEditorInput
):
void
;
...
...
src/vs/workbench/browser/parts/quickinput/quickInputList.ts
浏览文件 @
60c316f5
...
...
@@ -28,6 +28,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
getIconClass
}
from
'
vs/workbench/browser/parts/quickinput/quickInputUtils
'
;
import
{
IListOptions
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
const
$
=
dom
.
$
;
...
...
@@ -492,9 +493,9 @@ export class QuickInputList {
// Filter by value (since we support octicons, use octicon aware fuzzy matching)
else
{
this
.
elements
.
forEach
(
element
=>
{
const
labelHighlights
=
this
.
matchOnLabel
?
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
saneLabel
))
||
undefined
:
undefined
;
const
descriptionHighlights
=
this
.
matchOnDescription
?
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
saneDescription
||
''
))
||
undefined
:
undefined
;
const
detailHighlights
=
this
.
matchOnDetail
?
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
saneDetail
||
''
))
||
undefined
:
undefined
;
const
labelHighlights
=
this
.
matchOnLabel
?
withNullAsUndefined
(
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
saneLabel
)))
:
undefined
;
const
descriptionHighlights
=
this
.
matchOnDescription
?
withNullAsUndefined
(
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
saneDescription
||
''
)))
:
undefined
;
const
detailHighlights
=
this
.
matchOnDetail
?
withNullAsUndefined
(
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
saneDetail
||
''
)))
:
undefined
;
if
(
labelHighlights
||
descriptionHighlights
||
detailHighlights
)
{
element
.
labelHighlights
=
labelHighlights
;
...
...
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
浏览文件 @
60c316f5
...
...
@@ -848,7 +848,7 @@ export class RemoveFromEditorHistoryAction extends Action {
return
<
IHistoryPickEntry
>
{
input
:
h
,
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
entry
.
getResource
()
||
undefined
),
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
types
.
withNullAsUndefined
(
entry
.
getResource
())
),
label
:
entry
.
getLabel
(),
description
:
entry
.
getDescription
()
};
...
...
src/vs/workbench/browser/quickopen.ts
浏览文件 @
60c316f5
...
...
@@ -280,7 +280,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick
opts
=
EditorOptions
.
create
(
openOptions
);
}
this
.
editorService
.
openEditor
(
input
,
opts
||
undefined
,
sideBySide
?
SIDE_GROUP
:
ACTIVE_GROUP
);
this
.
editorService
.
openEditor
(
input
,
types
.
withNullAsUndefined
(
opts
)
,
sideBySide
?
SIDE_GROUP
:
ACTIVE_GROUP
);
}
else
{
const
resourceInput
=
<
IResourceInput
>
input
;
...
...
src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts
浏览文件 @
60c316f5
...
...
@@ -27,6 +27,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import
{
IEditorGroupsService
,
IEditorGroup
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
ResourceQueue
,
timeout
}
from
'
vs/base/common/async
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
class
FileEditorTracker
extends
Disposable
implements
IWorkbenchContribution
{
...
...
@@ -276,7 +277,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
if
(
editorResource
&&
resource
.
toString
()
===
editorResource
.
toString
())
{
const
control
=
editor
.
getControl
();
if
(
isCodeEditor
(
control
))
{
return
control
.
saveViewState
()
||
undefined
;
return
withNullAsUndefined
(
control
.
saveViewState
())
;
}
}
}
...
...
src/vs/workbench/contrib/preferences/electron-browser/settingsEditor2.ts
浏览文件 @
60c316f5
...
...
@@ -11,7 +11,7 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
import
*
as
collections
from
'
vs/base/common/collections
'
;
import
{
getErrorMessage
,
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
{
Iterator
}
from
'
vs/base/common/iterator
'
;
import
{
isArray
}
from
'
vs/base/common/types
'
;
import
{
isArray
,
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
'
vs/css!./media/settingsEditor2
'
;
import
{
localize
}
from
'
vs/nls
'
;
...
...
@@ -573,7 +573,7 @@ export class SettingsEditor2 extends BaseEditor {
this
.
tocTree
.
setSelection
(
element
?
[
element
]
:
[]);
if
(
this
.
searchResultModel
)
{
if
(
this
.
viewState
.
filterToCategory
!==
element
)
{
this
.
viewState
.
filterToCategory
=
element
||
undefined
;
this
.
viewState
.
filterToCategory
=
withNullAsUndefined
(
element
)
;
this
.
renderTree
();
this
.
settingsTree
.
scrollTop
=
0
;
}
...
...
src/vs/workbench/contrib/search/common/searchModel.ts
浏览文件 @
60c316f5
...
...
@@ -26,6 +26,7 @@ import { overviewRulerFindMatchForeground } from 'vs/platform/theme/common/color
import
{
themeColorFromId
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IReplaceService
}
from
'
vs/workbench/contrib/search/common/replace
'
;
import
{
editorMatchesToTextSearchResults
}
from
'
vs/workbench/services/search/common/searchHelpers
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
class
Match
{
...
...
@@ -440,7 +441,7 @@ export class BaseFolderMatch extends Disposable {
}
name
():
string
{
return
getBaseLabel
(
this
.
resource
()
||
undefined
)
||
''
;
return
getBaseLabel
(
withNullAsUndefined
(
this
.
resource
())
)
||
''
;
}
parent
():
SearchResult
{
...
...
src/vs/workbench/contrib/terminal/browser/terminalActions.ts
浏览文件 @
60c316f5
...
...
@@ -34,6 +34,7 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history';
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
const
TERMINAL_PICKER_PREFIX
=
'
term
'
;
...
...
@@ -291,7 +292,7 @@ export class SendSequenceTerminalCommand extends Command {
const
workspaceContextService
=
accessor
.
get
(
IWorkspaceContextService
);
const
historyService
=
accessor
.
get
(
IHistoryService
);
const
activeWorkspaceRootUri
=
historyService
.
getLastActiveWorkspaceRoot
(
Schemas
.
file
);
const
lastActiveWorkspaceRoot
=
activeWorkspaceRootUri
?
w
orkspaceContextService
.
getWorkspaceFolder
(
activeWorkspaceRootUri
)
||
undefined
:
undefined
;
const
lastActiveWorkspaceRoot
=
activeWorkspaceRootUri
?
w
ithNullAsUndefined
(
workspaceContextService
.
getWorkspaceFolder
(
activeWorkspaceRootUri
))
:
undefined
;
const
resolvedText
=
configurationResolverService
.
resolve
(
lastActiveWorkspaceRoot
,
args
.
text
);
terminalInstance
.
sendText
(
resolvedText
,
false
);
}
...
...
src/vs/workbench/services/configuration/common/configurationEditingService.ts
浏览文件 @
60c316f5
...
...
@@ -27,7 +27,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
withUndefinedAsNull
}
from
'
vs/base/common/types
'
;
import
{
withUndefinedAsNull
,
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
const
enum
ConfigurationEditingErrorCode
{
...
...
@@ -463,14 +463,14 @@ export class ConfigurationEditingService {
// Check for prefix
if
(
config
.
key
===
key
)
{
const
jsonPath
=
this
.
isWorkspaceConfigurationResource
(
resource
)
?
[
key
]
:
[];
return
{
key
:
jsonPath
[
jsonPath
.
length
-
1
],
jsonPath
,
value
:
config
.
value
,
resource
:
resource
||
undefined
,
workspaceStandAloneConfigurationKey
:
key
,
target
};
return
{
key
:
jsonPath
[
jsonPath
.
length
-
1
],
jsonPath
,
value
:
config
.
value
,
resource
:
withNullAsUndefined
(
resource
)
,
workspaceStandAloneConfigurationKey
:
key
,
target
};
}
// Check for prefix.<setting>
const
keyPrefix
=
`
${
key
}
.`
;
if
(
config
.
key
.
indexOf
(
keyPrefix
)
===
0
)
{
const
jsonPath
=
this
.
isWorkspaceConfigurationResource
(
resource
)
?
[
key
,
config
.
key
.
substr
(
keyPrefix
.
length
)]
:
[
config
.
key
.
substr
(
keyPrefix
.
length
)];
return
{
key
:
jsonPath
[
jsonPath
.
length
-
1
],
jsonPath
,
value
:
config
.
value
,
resource
:
resource
||
undefined
,
workspaceStandAloneConfigurationKey
:
key
,
target
};
return
{
key
:
jsonPath
[
jsonPath
.
length
-
1
],
jsonPath
,
value
:
config
.
value
,
resource
:
withNullAsUndefined
(
resource
)
,
workspaceStandAloneConfigurationKey
:
key
,
target
};
}
}
}
...
...
@@ -485,7 +485,7 @@ export class ConfigurationEditingService {
if
(
this
.
isWorkspaceConfigurationResource
(
resource
))
{
jsonPath
=
[
'
settings
'
,
...
jsonPath
];
}
return
{
key
,
jsonPath
,
value
:
config
.
value
,
resource
:
resource
||
undefined
,
target
};
return
{
key
,
jsonPath
,
value
:
config
.
value
,
resource
:
withNullAsUndefined
(
resource
)
,
target
};
}
private
isWorkspaceConfigurationResource
(
resource
:
URI
|
null
):
boolean
{
...
...
src/vs/workbench/services/extensions/electron-browser/extensionHostProfiler.ts
浏览文件 @
60c316f5
...
...
@@ -8,6 +8,7 @@ import { TernarySearchTree } from 'vs/base/common/map';
import
{
realpathSync
}
from
'
vs/base/node/extfs
'
;
import
{
IExtensionHostProfile
,
IExtensionService
,
ProfileSegmentId
,
ProfileSession
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
class
ExtensionHostProfiler
{
...
...
@@ -88,7 +89,7 @@ export class ExtensionHostProfiler {
distilledIds
.
push
(
currSegmentId
);
distilledDeltas
.
push
(
currSegmentTime
);
}
currSegmentId
=
segmentId
||
undefined
;
currSegmentId
=
withNullAsUndefined
(
segmentId
)
;
currSegmentTime
=
0
;
}
currSegmentTime
+=
timeDeltas
[
i
];
...
...
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
浏览文件 @
60c316f5
...
...
@@ -49,6 +49,7 @@ import { provideSelectionRanges } from 'vs/editor/contrib/smartSelect/smartSelec
import
{
mock
}
from
'
vs/workbench/test/electron-browser/api/mock
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
const
defaultSelector
=
{
scheme
:
'
far
'
};
const
model
:
ITextModel
=
EditorModel
.
createFromString
(
...
...
@@ -906,7 +907,7 @@ suite('ExtHostLanguageFeatures', function () {
const
NullWorkerService
=
new
class
extends
mock
<
IEditorWorkerService
>
()
{
computeMoreMinimalEdits
(
resource
:
URI
,
edits
:
modes
.
TextEdit
[]
|
null
|
undefined
):
Promise
<
modes
.
TextEdit
[]
|
undefined
>
{
return
Promise
.
resolve
(
edits
||
undefined
);
return
Promise
.
resolve
(
withNullAsUndefined
(
edits
)
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录