Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eebf4c7b
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,发现更多精彩内容 >>
提交
eebf4c7b
编写于
12月 02, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up move to beginning/end of line in cursor
上级
14aa8e71
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
60 deletion
+38
-60
src/vs/editor/common/controller/cursorMoveHelper.ts
src/vs/editor/common/controller/cursorMoveHelper.ts
+0
-37
src/vs/editor/common/controller/cursorMoveOperations.ts
src/vs/editor/common/controller/cursorMoveOperations.ts
+30
-0
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+8
-23
未找到文件。
src/vs/editor/common/controller/cursorMoveHelper.ts
已删除
100644 → 0
浏览文件 @
14aa8e71
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
export
class
CursorMoveHelper
{
public
static
getColumnAtBeginningOfLine
(
model
:
ICursorSimpleModel
,
lineNumber
:
number
,
column
:
number
):
number
{
var
firstNonBlankColumn
=
model
.
getLineFirstNonWhitespaceColumn
(
lineNumber
)
||
1
;
var
minColumn
=
model
.
getLineMinColumn
(
lineNumber
);
if
(
column
!==
minColumn
&&
column
<=
firstNonBlankColumn
)
{
column
=
minColumn
;
}
else
{
column
=
firstNonBlankColumn
;
}
return
column
;
}
public
static
getColumnAtEndOfLine
(
model
:
ICursorSimpleModel
,
lineNumber
:
number
,
column
:
number
):
number
{
var
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
var
lastNonBlankColumn
=
model
.
getLineLastNonWhitespaceColumn
(
lineNumber
)
||
maxColumn
;
if
(
column
!==
maxColumn
&&
column
>=
lastNonBlankColumn
)
{
column
=
maxColumn
;
}
else
{
column
=
lastNonBlankColumn
;
}
return
column
;
}
}
src/vs/editor/common/controller/cursorMoveOperations.ts
浏览文件 @
eebf4c7b
...
...
@@ -241,6 +241,36 @@ export class MoveOperations {
return
new
SingleMoveOperationResult
(
tmp
,
true
,
CursorChangeReason
.
Explicit
);
}
public
static
moveToBeginningOfLine
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
SingleMoveOperationResult
{
let
lineNumber
=
cursor
.
position
.
lineNumber
;
let
column
=
cursor
.
position
.
column
;
let
firstNonBlankColumn
=
model
.
getLineFirstNonWhitespaceColumn
(
lineNumber
)
||
1
;
let
minColumn
=
model
.
getLineMinColumn
(
lineNumber
);
if
(
column
!==
minColumn
&&
column
<=
firstNonBlankColumn
)
{
column
=
minColumn
;
}
else
{
column
=
firstNonBlankColumn
;
}
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lineNumber
,
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
}
public
static
moveToEndOfLine
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
SingleMoveOperationResult
{
let
lineNumber
=
cursor
.
position
.
lineNumber
;
let
column
=
cursor
.
position
.
column
;
let
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
let
lastNonBlankColumn
=
model
.
getLineLastNonWhitespaceColumn
(
lineNumber
)
||
maxColumn
;
if
(
column
!==
maxColumn
&&
column
>=
lastNonBlankColumn
)
{
column
=
maxColumn
;
}
else
{
column
=
lastNonBlankColumn
;
}
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lineNumber
,
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
}
public
static
moveToBeginningOfBuffer
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
SingleMoveOperationResult
{
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
1
,
1
,
0
,
true
,
CursorChangeReason
.
Explicit
);
}
...
...
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
eebf4c7b
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
{
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
CursorMoveHelper
}
from
'
vs/editor/common/controller/cursorMoveHelper
'
;
import
{
SingleCursorState
,
CursorConfiguration
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -512,12 +511,6 @@ export class OneCursor implements IOneCursor {
}
return
visibleRange
;
}
public
getColumnAtBeginningOfViewLine
(
lineNumber
:
number
,
column
:
number
):
number
{
return
CursorMoveHelper
.
getColumnAtBeginningOfLine
(
this
.
viewModel
,
lineNumber
,
column
);
}
public
getColumnAtEndOfViewLine
(
lineNumber
:
number
,
column
:
number
):
number
{
return
CursorMoveHelper
.
getColumnAtEndOfLine
(
this
.
viewModel
,
lineNumber
,
column
);
}
public
getNearestRevealViewPositionInViewport
():
Position
{
const
position
=
this
.
viewState
.
position
;
const
revealRange
=
this
.
getRevealViewLinesRangeInViewport
();
...
...
@@ -764,25 +757,17 @@ export class OneCursorOp {
}
public
static
moveToBeginningOfLine
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
validatedViewPosition
=
cursor
.
viewState
.
position
;
let
viewLineNumber
=
validatedViewPosition
.
lineNumber
;
let
viewColumn
=
validatedViewPosition
.
column
;
viewColumn
=
cursor
.
getColumnAtBeginningOfViewLine
(
viewLineNumber
,
viewColumn
);
ctx
.
cursorPositionChangeReason
=
editorCommon
.
CursorChangeReason
.
Explicit
;
cursor
.
moveViewPosition
(
inSelectionMode
,
viewLineNumber
,
viewColumn
,
0
,
true
);
return
true
;
return
this
.
_applyMoveOperationResult
(
cursor
,
ctx
,
this
.
_fromViewCursorState
(
cursor
,
MoveOperations
.
moveToBeginningOfLine
(
cursor
.
config
,
cursor
.
viewModel
,
cursor
.
viewState
,
inSelectionMode
))
);
}
public
static
moveToEndOfLine
(
cursor
:
OneCursor
,
inSelectionMode
:
boolean
,
ctx
:
IOneCursorOperationContext
):
boolean
{
let
validatedViewPosition
=
cursor
.
viewState
.
position
;
let
viewLineNumber
=
validatedViewPosition
.
lineNumber
;
let
viewColumn
=
validatedViewPosition
.
column
;
viewColumn
=
cursor
.
getColumnAtEndOfViewLine
(
viewLineNumber
,
viewColumn
);
ctx
.
cursorPositionChangeReason
=
editorCommon
.
CursorChangeReason
.
Explicit
;
cursor
.
moveViewPosition
(
inSelectionMode
,
viewLineNumber
,
viewColumn
,
0
,
true
);
return
true
;
return
this
.
_applyMoveOperationResult
(
cursor
,
ctx
,
this
.
_fromViewCursorState
(
cursor
,
MoveOperations
.
moveToEndOfLine
(
cursor
.
config
,
cursor
.
viewModel
,
cursor
.
viewState
,
inSelectionMode
))
);
}
public
static
expandLineSelection
(
cursor
:
OneCursor
,
ctx
:
IOneCursorOperationContext
):
boolean
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录