Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
98d8caf7
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,发现更多精彩内容 >>
未验证
提交
98d8caf7
编写于
2月 26, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #91361: Update selection when toggling column selection mode
上级
a980d877
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
4 deletion
+53
-4
src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts
...bench/contrib/codeEditor/browser/toggleColumnSelection.ts
+53
-4
未找到文件。
src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts
浏览文件 @
98d8caf7
...
...
@@ -10,6 +10,13 @@ import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configur
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Extensions
as
ActionExtensions
,
IWorkbenchActionRegistry
}
from
'
vs/workbench/common/actions
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CoreNavigationCommands
}
from
'
vs/editor/browser/controller/coreCommands
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
CursorColumns
}
from
'
vs/editor/common/controller/cursorCommon
'
;
export
class
ToggleColumnSelectionAction
extends
Action
{
public
static
readonly
ID
=
'
editor.action.toggleColumnSelection
'
;
...
...
@@ -18,14 +25,56 @@ export class ToggleColumnSelectionAction extends Action {
constructor
(
id
:
string
,
label
:
string
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
ICodeEditorService
private
readonly
_codeEditorService
:
ICodeEditorService
)
{
super
(
id
,
label
);
}
public
run
():
Promise
<
any
>
{
const
newValue
=
!
this
.
_configurationService
.
getValue
<
boolean
>
(
'
editor.columnSelection
'
);
return
this
.
_configurationService
.
updateValue
(
'
editor.columnSelection
'
,
newValue
,
ConfigurationTarget
.
USER
);
private
_getCodeEditor
():
ICodeEditor
|
null
{
const
codeEditor
=
this
.
_codeEditorService
.
getFocusedCodeEditor
();
if
(
codeEditor
)
{
return
codeEditor
;
}
return
this
.
_codeEditorService
.
getActiveCodeEditor
();
}
public
async
run
():
Promise
<
any
>
{
const
oldValue
=
this
.
_configurationService
.
getValue
<
boolean
>
(
'
editor.columnSelection
'
);
const
codeEditor
=
this
.
_getCodeEditor
();
await
this
.
_configurationService
.
updateValue
(
'
editor.columnSelection
'
,
!
oldValue
,
ConfigurationTarget
.
USER
);
const
newValue
=
this
.
_configurationService
.
getValue
<
boolean
>
(
'
editor.columnSelection
'
);
if
(
!
codeEditor
||
codeEditor
!==
this
.
_getCodeEditor
()
||
oldValue
===
newValue
||
!
codeEditor
.
hasModel
())
{
return
;
}
const
cursors
=
codeEditor
.
_getCursors
();
if
(
codeEditor
.
getOption
(
EditorOption
.
columnSelection
))
{
const
selection
=
codeEditor
.
getSelection
();
const
modelSelectionStart
=
new
Position
(
selection
.
selectionStartLineNumber
,
selection
.
selectionStartColumn
);
const
viewSelectionStart
=
cursors
.
context
.
convertModelPositionToViewPosition
(
modelSelectionStart
);
const
modelPosition
=
new
Position
(
selection
.
positionLineNumber
,
selection
.
positionColumn
);
const
viewPosition
=
cursors
.
context
.
convertModelPositionToViewPosition
(
modelPosition
);
CoreNavigationCommands
.
MoveTo
.
runCoreEditorCommand
(
cursors
,
{
position
:
modelSelectionStart
,
viewPosition
:
viewSelectionStart
});
const
visibleColumn
=
CursorColumns
.
visibleColumnFromColumn2
(
cursors
.
context
.
config
,
cursors
.
context
.
viewModel
,
viewPosition
);
CoreNavigationCommands
.
ColumnSelect
.
runCoreEditorCommand
(
cursors
,
{
position
:
modelPosition
,
viewPosition
:
viewPosition
,
doColumnSelect
:
true
,
mouseColumn
:
visibleColumn
+
1
});
}
else
{
const
columnSelectData
=
cursors
.
getColumnSelectData
();
const
fromViewColumn
=
CursorColumns
.
columnFromVisibleColumn2
(
cursors
.
context
.
config
,
cursors
.
context
.
viewModel
,
columnSelectData
.
fromViewLineNumber
,
columnSelectData
.
fromViewVisualColumn
);
const
fromPosition
=
cursors
.
context
.
convertViewPositionToModelPosition
(
columnSelectData
.
fromViewLineNumber
,
fromViewColumn
);
const
toViewColumn
=
CursorColumns
.
columnFromVisibleColumn2
(
cursors
.
context
.
config
,
cursors
.
context
.
viewModel
,
columnSelectData
.
toViewLineNumber
,
columnSelectData
.
toViewVisualColumn
);
const
toPosition
=
cursors
.
context
.
convertViewPositionToModelPosition
(
columnSelectData
.
toViewLineNumber
,
toViewColumn
);
codeEditor
.
setSelection
(
new
Selection
(
fromPosition
.
lineNumber
,
fromPosition
.
column
,
toPosition
.
lineNumber
,
toPosition
.
column
));
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录