Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
旅途_2012
vscode
提交
46c86891
V
vscode
项目概览
旅途_2012
/
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,发现更多精彩内容 >>
提交
46c86891
编写于
9月 09, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix behaviour with multiline vs singleline snippets and their final cursor position, #11742
上级
e1b6d7de
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
28 addition
and
10 deletion
+28
-10
src/vs/editor/contrib/snippet/common/snippetController.ts
src/vs/editor/contrib/snippet/common/snippetController.ts
+15
-10
src/vs/editor/contrib/snippet/test/common/snippetController.test.ts
...tor/contrib/snippet/test/common/snippetController.test.ts
+13
-0
未找到文件。
src/vs/editor/contrib/snippet/common/snippetController.ts
浏览文件 @
46c86891
...
...
@@ -484,7 +484,7 @@ export class SnippetController {
const
edits
:
editorCommon
.
IIdentifiedSingleEditOperation
[]
=
[];
const
selections
=
this
.
_editor
.
getSelections
();
let
lineDelta
=
0
;
let
columnDelta
=
0
;
let
columnDelta
OrValue
=
0
;
for
(
let
i
=
0
;
i
<
selections
.
length
;
i
++
)
{
let
{
adaptedSnippet
,
typeRange
}
=
SnippetController
.
_prepareSnippet
(
this
.
_editor
,
selections
[
i
],
snippet
,
overwriteBefore
,
overwriteAfter
,
stripPrefix
);
...
...
@@ -492,12 +492,13 @@ export class SnippetController {
if
(
i
===
0
&&
snippet
.
isSingleTabstopOnly
)
{
const
finalCursorPos
=
SnippetController
.
_getSnippetCursorOnly
(
adaptedSnippet
);
const
editEnd
=
typeRange
.
getEndPosition
();
editEnd
.
lineNumber
+=
adaptedSnippet
.
lines
.
length
-
1
;
editEnd
.
column
=
adaptedSnippet
.
lines
[
adaptedSnippet
.
lines
.
length
-
1
].
length
+
1
;
lineDelta
=
finalCursorPos
.
lineNumber
-
editEnd
.
lineNumber
;
columnDelta
=
finalCursorPos
.
column
-
editEnd
.
column
;
lineDelta
=
finalCursorPos
.
lineNumber
-
typeRange
.
startLineNumber
;
if
(
lineDelta
===
0
)
{
columnDeltaOrValue
=
finalCursorPos
.
column
-
typeRange
.
startColumn
;
}
else
{
columnDeltaOrValue
=
finalCursorPos
.
column
;
}
}
}
...
...
@@ -509,11 +510,15 @@ export class SnippetController {
return
inverseEdits
.
map
((
edit
,
i
)
=>
{
let
{
endLineNumber
,
endColumn
}
=
edit
.
range
;
endLineNumber
+=
lineDelta
;
endColumn
+=
columnDelta
;
let
{
startLineNumber
,
startColumn
}
=
edit
.
range
;
if
(
lineDelta
===
0
)
{
startColumn
+=
columnDeltaOrValue
;
}
else
{
startLineNumber
+=
lineDelta
;
startColumn
+=
columnDeltaOrValue
;
}
return
new
Selection
(
endLineNumber
,
endColumn
,
endLineNumber
,
end
Column
);
return
new
Selection
(
startLineNumber
,
startColumn
,
startLineNumber
,
start
Column
);
});
};
...
...
src/vs/editor/contrib/snippet/test/common/snippetController.test.ts
浏览文件 @
46c86891
...
...
@@ -281,5 +281,18 @@ suite('SnippetController', () => {
assert
.
ok
(
first
.
equalsRange
({
startLineNumber
:
2
,
startColumn
:
1
,
endLineNumber
:
2
,
endColumn
:
1
}),
first
.
toString
());
assert
.
ok
(
second
.
equalsRange
({
startLineNumber
:
4
,
startColumn
:
1
,
endLineNumber
:
4
,
endColumn
:
1
}),
second
.
toString
());
});
snippetTest
((
editor
,
cursor
,
codeSnippet
,
snippetController
)
=>
{
editor
.
setSelections
([
new
Selection
(
2
,
7
,
2
,
7
)
]);
codeSnippet
=
CodeSnippet
.
fromInternal
(
'
xx{{}}yy
'
);
snippetController
.
run
(
codeSnippet
,
1
,
0
,
false
);
assert
.
equal
(
editor
.
getSelections
().
length
,
1
);
const
[
first
]
=
editor
.
getSelections
();
assert
.
ok
(
first
.
equalsRange
({
startLineNumber
:
2
,
startColumn
:
8
,
endLineNumber
:
2
,
endColumn
:
8
}),
first
.
toString
());
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录