Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
026df274
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,发现更多精彩内容 >>
提交
026df274
编写于
11月 09, 2018
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lines operations strict null check.
#60565.
上级
914c6d96
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
89 addition
and
14 deletion
+89
-14
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+1
-0
src/vs/editor/common/controller/cursorTypeOperations.ts
src/vs/editor/common/controller/cursorTypeOperations.ts
+15
-3
src/vs/editor/contrib/linesOperations/linesOperations.ts
src/vs/editor/contrib/linesOperations/linesOperations.ts
+68
-10
src/vs/editor/contrib/linesOperations/sortLinesCommand.ts
src/vs/editor/contrib/linesOperations/sortLinesCommand.ts
+5
-1
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
026df274
...
...
@@ -337,6 +337,7 @@
"./vs/editor/contrib/linesOperations/deleteLinesCommand.ts"
,
"./vs/editor/contrib/linesOperations/moveLinesCommand.ts"
,
"./vs/editor/contrib/linesOperations/sortLinesCommand.ts"
,
"./vs/editor/contrib/linesOperations/linesOperations.ts"
,
"./vs/editor/contrib/links/getLinks.ts"
,
"./vs/editor/contrib/links/links.ts"
,
"./vs/editor/contrib/markdown/markdownRenderer.ts"
,
...
...
src/vs/editor/common/controller/cursorTypeOperations.ts
浏览文件 @
026df274
...
...
@@ -21,7 +21,11 @@ import { IElectricAction } from 'vs/editor/common/modes/supports/electricCharact
export
class
TypeOperations
{
public
static
indent
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
selections
:
Selection
[]):
ICommand
[]
{
public
static
indent
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
|
null
,
selections
:
Selection
[]
|
null
):
ICommand
[]
{
if
(
model
===
null
||
selections
===
null
)
{
return
[];
}
let
commands
:
ICommand
[]
=
[];
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
commands
[
i
]
=
new
ShiftCommand
(
selections
[
i
],
{
...
...
@@ -885,7 +889,11 @@ export class TypeOperations {
});
}
public
static
lineInsertBefore
(
config
:
CursorConfiguration
,
model
:
ITextModel
,
selections
:
Selection
[]):
ICommand
[]
{
public
static
lineInsertBefore
(
config
:
CursorConfiguration
,
model
:
ITextModel
|
null
,
selections
:
Selection
[]
|
null
):
ICommand
[]
{
if
(
model
===
null
||
selections
===
null
)
{
return
[];
}
let
commands
:
ICommand
[]
=
[];
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
let
lineNumber
=
selections
[
i
].
positionLineNumber
;
...
...
@@ -902,7 +910,11 @@ export class TypeOperations {
return
commands
;
}
public
static
lineInsertAfter
(
config
:
CursorConfiguration
,
model
:
ITextModel
,
selections
:
Selection
[]):
ICommand
[]
{
public
static
lineInsertAfter
(
config
:
CursorConfiguration
,
model
:
ITextModel
|
null
,
selections
:
Selection
[]
|
null
):
ICommand
[]
{
if
(
model
===
null
||
selections
===
null
)
{
return
[];
}
let
commands
:
ICommand
[]
=
[];
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
const
lineNumber
=
selections
[
i
].
positionLineNumber
;
...
...
src/vs/editor/contrib/linesOperations/linesOperations.ts
浏览文件 @
026df274
...
...
@@ -249,7 +249,12 @@ export class TrimTrailingWhitespaceAction extends EditorAction {
cursors
=
(
editor
.
getSelections
()
||
[]).
map
(
s
=>
new
Position
(
s
.
positionLineNumber
,
s
.
positionColumn
));
}
let
command
=
new
TrimTrailingWhitespaceCommand
(
editor
.
getSelection
(),
cursors
);
let
selection
=
editor
.
getSelection
();
if
(
selection
===
null
)
{
return
;
}
let
command
=
new
TrimTrailingWhitespaceCommand
(
selection
,
cursors
);
editor
.
pushUndoStop
();
editor
.
executeCommands
(
this
.
id
,
[
command
]);
...
...
@@ -297,7 +302,11 @@ class DeleteLinesAction extends EditorAction {
private
_getLinesToRemove
(
editor
:
ICodeEditor
):
IDeleteLinesOperation
[]
{
// Construct delete operations
let
operations
:
IDeleteLinesOperation
[]
=
editor
.
getSelections
().
map
((
s
)
=>
{
let
selections
=
editor
.
getSelections
();
if
(
selections
===
null
)
{
return
[];
}
let
operations
:
IDeleteLinesOperation
[]
=
selections
.
map
((
s
)
=>
{
let
endLineNumber
=
s
.
endLineNumber
;
if
(
s
.
startLineNumber
<
s
.
endLineNumber
&&
s
.
endColumn
===
1
)
{
...
...
@@ -378,7 +387,7 @@ class OutdentLinesAction extends EditorAction {
}
public
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
{
CoreEditingCommands
.
Outdent
.
runEditorCommand
(
null
,
editor
,
null
);
CoreEditingCommands
.
Outdent
.
runEditorCommand
(
_accessor
,
editor
,
null
);
}
}
...
...
@@ -435,6 +444,10 @@ export class InsertLineAfterAction extends EditorAction {
export
abstract
class
AbstractDeleteAllToBoundaryAction
extends
EditorAction
{
public
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
{
const
primaryCursor
=
editor
.
getSelection
();
if
(
primaryCursor
===
null
)
{
return
;
}
let
rangesToDelete
=
this
.
_getRangesToDelete
(
editor
);
// merge overlapping selections
let
effectiveRanges
:
Range
[]
=
[];
...
...
@@ -488,7 +501,7 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
}
_getEndCursorState
(
primaryCursor
:
Range
,
rangesToDelete
:
Range
[]):
Selection
[]
{
let
endPrimaryCursor
:
Selection
;
let
endPrimaryCursor
:
Selection
|
null
=
null
;
let
endCursorState
:
Selection
[]
=
[];
let
deletedLines
=
0
;
...
...
@@ -518,15 +531,24 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
}
_getRangesToDelete
(
editor
:
ICodeEditor
):
Range
[]
{
let
rangesToDelete
:
Range
[]
=
editor
.
getSelections
();
let
selections
=
editor
.
getSelections
();
if
(
selections
===
null
)
{
return
[];
}
let
rangesToDelete
:
Range
[]
=
selections
;
let
model
=
editor
.
getModel
();
if
(
model
===
null
)
{
return
[];
}
rangesToDelete
.
sort
(
Range
.
compareRangesUsingStarts
);
rangesToDelete
=
rangesToDelete
.
map
(
selection
=>
{
if
(
selection
.
isEmpty
())
{
if
(
selection
.
startColumn
===
1
)
{
let
deleteFromLine
=
Math
.
max
(
1
,
selection
.
startLineNumber
-
1
);
let
deleteFromColumn
=
selection
.
startLineNumber
===
1
?
1
:
model
.
getLineContent
(
deleteFromLine
).
length
+
1
;
let
deleteFromColumn
=
selection
.
startLineNumber
===
1
?
1
:
model
!
.
getLineContent
(
deleteFromLine
).
length
+
1
;
return
new
Range
(
deleteFromLine
,
deleteFromColumn
,
selection
.
startLineNumber
,
1
);
}
else
{
return
new
Range
(
selection
.
startLineNumber
,
1
,
selection
.
startLineNumber
,
selection
.
startColumn
);
...
...
@@ -557,7 +579,7 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
}
_getEndCursorState
(
primaryCursor
:
Range
,
rangesToDelete
:
Range
[]):
Selection
[]
{
let
endPrimaryCursor
:
Selection
;
let
endPrimaryCursor
:
Selection
|
null
=
null
;
let
endCursorState
:
Selection
[]
=
[];
for
(
let
i
=
0
,
len
=
rangesToDelete
.
length
,
offset
=
0
;
i
<
len
;
i
++
)
{
let
range
=
rangesToDelete
[
i
];
...
...
@@ -579,10 +601,19 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
_getRangesToDelete
(
editor
:
ICodeEditor
):
Range
[]
{
let
model
=
editor
.
getModel
();
if
(
model
===
null
)
{
return
[];
}
let
rangesToDelete
:
Range
[]
=
editor
.
getSelections
().
map
((
sel
)
=>
{
let
selections
=
editor
.
getSelections
();
if
(
selections
===
null
)
{
return
[];
}
let
rangesToDelete
:
Range
[]
=
selections
.
map
((
sel
)
=>
{
if
(
sel
.
isEmpty
())
{
const
maxColumn
=
model
.
getLineMaxColumn
(
sel
.
startLineNumber
);
const
maxColumn
=
model
!
.
getLineMaxColumn
(
sel
.
startLineNumber
);
if
(
sel
.
startColumn
===
maxColumn
)
{
return
new
Range
(
sel
.
startLineNumber
,
sel
.
startColumn
,
sel
.
startLineNumber
+
1
,
1
);
...
...
@@ -616,7 +647,14 @@ export class JoinLinesAction extends EditorAction {
public
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
{
let
selections
=
editor
.
getSelections
();
if
(
selections
===
null
)
{
return
;
}
let
primaryCursor
=
editor
.
getSelection
();
if
(
primaryCursor
===
null
)
{
return
;
}
selections
.
sort
(
Range
.
compareRangesUsingStarts
);
let
reducedSelections
:
Selection
[]
=
[];
...
...
@@ -624,7 +662,7 @@ export class JoinLinesAction extends EditorAction {
let
lastSelection
=
selections
.
reduce
((
previousValue
,
currentValue
)
=>
{
if
(
previousValue
.
isEmpty
())
{
if
(
previousValue
.
endLineNumber
===
currentValue
.
startLineNumber
)
{
if
(
primaryCursor
.
equalsSelection
(
previousValue
))
{
if
(
primaryCursor
!
.
equalsSelection
(
previousValue
))
{
primaryCursor
=
currentValue
;
}
return
currentValue
;
...
...
@@ -649,6 +687,10 @@ export class JoinLinesAction extends EditorAction {
reducedSelections
.
push
(
lastSelection
);
let
model
=
editor
.
getModel
();
if
(
model
===
null
)
{
return
;
}
let
edits
:
IIdentifiedSingleEditOperation
[]
=
[];
let
endCursorState
:
Selection
[]
=
[];
let
endPrimaryCursor
=
primaryCursor
;
...
...
@@ -759,7 +801,15 @@ export class TransposeAction extends EditorAction {
public
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
{
let
selections
=
editor
.
getSelections
();
if
(
selections
===
null
)
{
return
;
}
let
model
=
editor
.
getModel
();
if
(
model
===
null
)
{
return
;
}
let
commands
:
ICommand
[]
=
[];
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
...
...
@@ -800,7 +850,15 @@ export class TransposeAction extends EditorAction {
export
abstract
class
AbstractCaseAction
extends
EditorAction
{
public
run
(
_accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
{
let
selections
=
editor
.
getSelections
();
if
(
selections
===
null
)
{
return
;
}
let
model
=
editor
.
getModel
();
if
(
model
===
null
)
{
return
;
}
let
commands
:
ICommand
[]
=
[];
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
...
...
src/vs/editor/contrib/linesOperations/sortLinesCommand.ts
浏览文件 @
026df274
...
...
@@ -33,7 +33,11 @@ export class SortLinesCommand implements editorCommon.ICommand {
return
helper
.
getTrackedSelection
(
this
.
selectionId
);
}
public
static
canRun
(
model
:
ITextModel
,
selection
:
Selection
,
descending
:
boolean
):
boolean
{
public
static
canRun
(
model
:
ITextModel
|
null
,
selection
:
Selection
,
descending
:
boolean
):
boolean
{
if
(
model
===
null
)
{
return
false
;
}
let
data
=
getSortData
(
model
,
selection
,
descending
);
if
(
!
data
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录