Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
51de5e57
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
51de5e57
编写于
9月 25, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Style changes
上级
23d53e96
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
26 deletion
+24
-26
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
+24
-26
未找到文件。
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
浏览文件 @
51de5e57
...
...
@@ -26,12 +26,12 @@ export class BlockCommentCommand implements editorCommon.ICommand {
if
(
offset
<
0
)
{
return
false
;
}
var
needleLength
=
needle
.
length
;
var
haystackLength
=
haystack
.
length
;
const
needleLength
=
needle
.
length
;
const
haystackLength
=
haystack
.
length
;
if
(
offset
+
needleLength
>
haystackLength
)
{
return
false
;
}
for
(
var
i
=
0
;
i
<
needleLength
;
i
++
)
{
for
(
let
i
=
0
;
i
<
needleLength
;
i
++
)
{
if
(
haystack
.
charCodeAt
(
offset
+
i
)
!==
needle
.
charCodeAt
(
i
))
{
return
false
;
}
...
...
@@ -40,21 +40,21 @@ export class BlockCommentCommand implements editorCommon.ICommand {
}
private
_createOperationsForBlockComment
(
selection
:
Range
,
config
:
ICommentsConfiguration
,
model
:
editorCommon
.
ITokenizedModel
,
builder
:
editorCommon
.
IEditOperationBuilder
):
void
{
var
startLineNumber
=
selection
.
startLineNumber
;
var
startColumn
=
selection
.
startColumn
;
var
endLineNumber
=
selection
.
endLineNumber
;
var
endColumn
=
selection
.
endColumn
;
const
startLineNumber
=
selection
.
startLineNumber
;
const
startColumn
=
selection
.
startColumn
;
const
endLineNumber
=
selection
.
endLineNumber
;
const
endColumn
=
selection
.
endColumn
;
var
startToken
=
config
.
blockCommentStartToken
;
var
endToken
=
config
.
blockCommentEndToken
;
let
startToken
=
config
.
blockCommentStartToken
;
let
endToken
=
config
.
blockCommentEndToken
;
var
startTokenIndex
=
model
.
getLineContent
(
startLineNumber
).
lastIndexOf
(
startToken
,
startColumn
-
1
+
startToken
.
length
);
var
endTokenIndex
=
model
.
getLineContent
(
endLineNumber
).
indexOf
(
endToken
,
endColumn
-
1
-
endToken
.
length
);
const
startTokenIndex
=
model
.
getLineContent
(
startLineNumber
).
lastIndexOf
(
startToken
,
startColumn
-
1
+
startToken
.
length
);
let
endTokenIndex
=
model
.
getLineContent
(
endLineNumber
).
indexOf
(
endToken
,
endColumn
-
1
-
endToken
.
length
);
var
ops
:
editorCommon
.
IIdentifiedSingleEditOperation
[];
let
ops
:
editorCommon
.
IIdentifiedSingleEditOperation
[];
if
(
startTokenIndex
!==
-
1
&&
endTokenIndex
!==
-
1
)
{
var
endTokenBeforeCursorIndex
=
model
.
getLineContent
(
startLineNumber
).
lastIndexOf
(
endToken
,
startColumn
-
1
+
endToken
.
length
);
const
endTokenBeforeCursorIndex
=
model
.
getLineContent
(
startLineNumber
).
lastIndexOf
(
endToken
,
startColumn
-
1
+
endToken
.
length
);
if
(
endTokenBeforeCursorIndex
>
startTokenIndex
+
startToken
.
length
-
1
)
{
ops
=
BlockCommentCommand
.
_createAddBlockCommentOperations
(
selection
,
startToken
,
endToken
);
this
.
_usedEndToken
=
ops
.
length
===
1
?
endToken
:
null
;
...
...
@@ -78,13 +78,13 @@ export class BlockCommentCommand implements editorCommon.ICommand {
this
.
_usedEndToken
=
ops
.
length
===
1
?
endToken
:
null
;
}
for
(
var
i
=
0
;
i
<
ops
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
ops
.
length
;
i
++
)
{
builder
.
addTrackedEditOperation
(
ops
[
i
].
range
,
ops
[
i
].
text
);
}
}
public
static
_createRemoveBlockCommentOperations
(
r
:
Range
,
startToken
:
string
,
endToken
:
string
):
editorCommon
.
IIdentifiedSingleEditOperation
[]
{
var
res
:
editorCommon
.
IIdentifiedSingleEditOperation
[]
=
[];
let
res
:
editorCommon
.
IIdentifiedSingleEditOperation
[]
=
[];
if
(
!
Range
.
isEmpty
(
r
))
{
// Remove block comment start
...
...
@@ -110,7 +110,7 @@ export class BlockCommentCommand implements editorCommon.ICommand {
}
public
static
_createAddBlockCommentOperations
(
r
:
Range
,
startToken
:
string
,
endToken
:
string
):
editorCommon
.
IIdentifiedSingleEditOperation
[]
{
var
res
:
editorCommon
.
IIdentifiedSingleEditOperation
[]
=
[];
let
res
:
editorCommon
.
IIdentifiedSingleEditOperation
[]
=
[];
if
(
!
Range
.
isEmpty
(
r
))
{
// Insert block comment start
...
...
@@ -130,10 +130,8 @@ export class BlockCommentCommand implements editorCommon.ICommand {
}
public
getEditOperations
(
model
:
editorCommon
.
ITokenizedModel
,
builder
:
editorCommon
.
IEditOperationBuilder
):
void
{
var
startLineNumber
=
this
.
_selection
.
startLineNumber
;
var
startColumn
=
this
.
_selection
.
startColumn
;
var
endLineNumber
=
this
.
_selection
.
endLineNumber
;
var
endColumn
=
this
.
_selection
.
endColumn
;
const
startLineNumber
=
this
.
_selection
.
startLineNumber
;
const
startColumn
=
this
.
_selection
.
startColumn
;
model
.
tokenizeIfCheap
(
startLineNumber
);
let
languageId
=
model
.
getLanguageIdAtPosition
(
startLineNumber
,
startColumn
);
...
...
@@ -144,15 +142,15 @@ export class BlockCommentCommand implements editorCommon.ICommand {
}
this
.
_createOperationsForBlockComment
(
new
Range
(
startLineNumber
,
startColumn
,
endLineNumber
,
endColumn
)
,
config
,
model
,
builder
this
.
_selection
,
config
,
model
,
builder
);
}
public
computeCursorState
(
model
:
editorCommon
.
ITokenizedModel
,
helper
:
editorCommon
.
ICursorStateComputerData
):
Selection
{
var
inverseEditOperations
=
helper
.
getInverseEditOperations
();
const
inverseEditOperations
=
helper
.
getInverseEditOperations
();
if
(
inverseEditOperations
.
length
===
2
)
{
var
startTokenEditOperation
=
inverseEditOperations
[
0
];
var
endTokenEditOperation
=
inverseEditOperations
[
1
];
const
startTokenEditOperation
=
inverseEditOperations
[
0
];
const
endTokenEditOperation
=
inverseEditOperations
[
1
];
return
new
Selection
(
startTokenEditOperation
.
range
.
endLineNumber
,
...
...
@@ -161,8 +159,8 @@ export class BlockCommentCommand implements editorCommon.ICommand {
endTokenEditOperation
.
range
.
startColumn
);
}
else
{
var
srcRange
=
inverseEditOperations
[
0
].
range
;
var
deltaColumn
=
this
.
_usedEndToken
?
-
this
.
_usedEndToken
.
length
-
1
:
0
;
// minus 1 space before endToken
const
srcRange
=
inverseEditOperations
[
0
].
range
;
const
deltaColumn
=
this
.
_usedEndToken
?
-
this
.
_usedEndToken
.
length
-
1
:
0
;
// minus 1 space before endToken
return
new
Selection
(
srcRange
.
endLineNumber
,
srcRange
.
endColumn
+
deltaColumn
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录