Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9d46f708
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d46f708
编写于
6月 28, 2017
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #29755. Adjust cursor position when pressing enter inside leading spaces.
上级
91e83d48
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
6 deletion
+27
-6
src/vs/editor/common/controller/cursorTypeOperations.ts
src/vs/editor/common/controller/cursorTypeOperations.ts
+26
-5
src/vs/editor/common/modes/languageConfigurationRegistry.ts
src/vs/editor/common/modes/languageConfigurationRegistry.ts
+1
-1
未找到文件。
src/vs/editor/common/controller/cursorTypeOperations.ts
浏览文件 @
9d46f708
...
@@ -310,13 +310,34 @@ export class TypeOperations {
...
@@ -310,13 +310,34 @@ export class TypeOperations {
let
lineText
=
model
.
getLineContent
(
range
.
startLineNumber
);
let
lineText
=
model
.
getLineContent
(
range
.
startLineNumber
);
let
indentation
=
strings
.
getLeadingWhitespace
(
lineText
).
substring
(
0
,
range
.
startColumn
-
1
);
let
indentation
=
strings
.
getLeadingWhitespace
(
lineText
).
substring
(
0
,
range
.
startColumn
-
1
);
if
(
ir
)
{
if
(
ir
)
{
if
(
/^
\s
+$/
.
test
(
lineText
)
||
indentation
===
config
.
normalizeIndentation
(
ir
.
beforeEnter
))
{
let
beforeText
=
'
\n
'
;
return
TypeOperations
.
_typeCommand
(
range
,
'
\n
'
+
config
.
normalizeIndentation
(
ir
.
afterEnter
),
keepPosition
);
let
isSelectionEmpty
=
range
.
isEmpty
();
if
(
indentation
!==
config
.
normalizeIndentation
(
ir
.
beforeEnter
))
{
beforeText
=
config
.
normalizeIndentation
(
ir
.
beforeEnter
)
+
lineText
.
substring
(
indentation
.
length
,
range
.
startColumn
-
1
)
+
'
\n
'
;
range
=
new
Range
(
range
.
startLineNumber
,
1
,
range
.
endLineNumber
,
range
.
endColumn
);
}
let
newLineContent
=
model
.
getLineContent
(
range
.
endLineNumber
);
let
oldEndColumn
=
CursorColumns
.
visibleColumnFromColumn2
(
config
,
model
,
range
.
getEndPosition
());
if
(
!
config
.
insertSpaces
)
{
oldEndColumn
=
Math
.
ceil
(
oldEndColumn
/
config
.
tabSize
)
+
1
;
}
let
firstNonWhitespace
=
strings
.
firstNonWhitespaceIndex
(
newLineContent
);
if
(
firstNonWhitespace
>=
0
)
{
range
=
range
.
setEndPosition
(
range
.
endLineNumber
,
Math
.
max
(
range
.
endColumn
,
firstNonWhitespace
+
1
));
}
else
{
range
=
range
.
setEndPosition
(
range
.
endLineNumber
,
model
.
getLineMaxColumn
(
range
.
endLineNumber
));
}
}
let
beforeText
=
config
.
normalizeIndentation
(
ir
.
beforeEnter
)
+
lineText
.
substring
(
indentation
.
length
,
range
.
startColumn
-
1
);
range
=
new
Range
(
range
.
startLineNumber
,
1
,
range
.
endLineNumber
,
range
.
endColumn
);
if
(
keepPosition
)
{
return
TypeOperations
.
_typeCommand
(
range
,
beforeText
+
'
\n
'
+
config
.
normalizeIndentation
(
ir
.
afterEnter
),
keepPosition
);
return
new
ReplaceCommandWithoutChangingPosition
(
range
,
beforeText
+
config
.
normalizeIndentation
(
ir
.
afterEnter
),
true
);
}
else
{
let
offset
=
isSelectionEmpty
?
oldEndColumn
-
config
.
normalizeIndentation
(
ir
.
afterEnter
).
length
-
1
:
0
;
return
new
ReplaceCommandWithOffsetCursorState
(
range
,
beforeText
+
config
.
normalizeIndentation
(
ir
.
afterEnter
),
0
,
offset
,
true
);
}
}
else
{
}
else
{
return
TypeOperations
.
_typeCommand
(
range
,
'
\n
'
+
config
.
normalizeIndentation
(
indentation
),
keepPosition
);
return
TypeOperations
.
_typeCommand
(
range
,
'
\n
'
+
config
.
normalizeIndentation
(
indentation
),
keepPosition
);
}
}
...
...
src/vs/editor/common/modes/languageConfigurationRegistry.ts
浏览文件 @
9d46f708
...
@@ -294,7 +294,7 @@ export class LanguageConfigurationRegistryImpl {
...
@@ -294,7 +294,7 @@ export class LanguageConfigurationRegistryImpl {
return
resultLineNumber
;
return
resultLineNumber
;
}
}
let
text
=
model
.
getLineContent
(
lastLineNumber
);
let
text
=
model
.
getLineContent
(
lastLineNumber
);
if
(
indentRulesSupport
.
shouldIgnore
(
text
)
||
text
===
''
)
{
if
(
indentRulesSupport
.
shouldIgnore
(
text
)
||
/^
\s
+$/
.
test
(
text
)
||
text
===
''
)
{
resultLineNumber
=
lastLineNumber
;
resultLineNumber
=
lastLineNumber
;
continue
;
continue
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录