Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
340110ff
V
vscode
项目概览
掘金者说
/
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,发现更多精彩内容 >>
提交
340110ff
编写于
5月 23, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Review cursor position/selection change listeners (#26730)
上级
00018cc6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
15 deletion
+62
-15
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+11
-7
src/vs/editor/contrib/bracketMatching/common/bracketMatching.ts
.../editor/contrib/bracketMatching/common/bracketMatching.ts
+10
-1
src/vs/editor/contrib/find/common/findController.ts
src/vs/editor/contrib/find/common/findController.ts
+15
-3
src/vs/editor/contrib/folding/browser/folding.ts
src/vs/editor/contrib/folding/browser/folding.ts
+10
-1
src/vs/editor/contrib/suggest/browser/suggestModel.ts
src/vs/editor/contrib/suggest/browser/suggestModel.ts
+6
-0
src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts
.../editor/contrib/wordHighlighter/common/wordHighlighter.ts
+7
-0
src/vs/workbench/services/history/browser/history.ts
src/vs/workbench/services/history/browser/history.ts
+3
-3
未找到文件。
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
340110ff
...
...
@@ -765,6 +765,7 @@ export interface IValidatedEditorOptions {
readonly
dragAndDrop
:
boolean
;
readonly
emptySelectionClipboard
:
boolean
;
readonly
useTabStops
:
boolean
;
readonly
performanceCritical
:
boolean
;
readonly
viewInfo
:
InternalEditorViewOptions
;
readonly
contribInfo
:
EditorContribOptions
;
...
...
@@ -1344,8 +1345,9 @@ export class EditorOptionsValidator {
wordWrap
=
_stringSet
<
'
off
'
|
'
on
'
|
'
wordWrapColumn
'
|
'
bounded
'
>
(
wordWrap
,
defaults
.
wordWrap
,
[
'
off
'
,
'
on
'
,
'
wordWrapColumn
'
,
'
bounded
'
]);
}
const
performanceCritical
=
false
;
const
viewInfo
=
this
.
_sanitizeViewInfo
(
opts
,
defaults
.
viewInfo
);
const
contribInfo
=
this
.
_sanitizeContribInfo
(
opts
,
defaults
.
contribInfo
);
const
contribInfo
=
this
.
_sanitizeContribInfo
(
opts
,
defaults
.
contribInfo
,
performanceCritical
);
return
{
inDiffEditor
:
_boolean
(
opts
.
inDiffEditor
,
defaults
.
inDiffEditor
),
...
...
@@ -1367,6 +1369,7 @@ export class EditorOptionsValidator {
dragAndDrop
:
_boolean
(
opts
.
dragAndDrop
,
defaults
.
dragAndDrop
),
emptySelectionClipboard
:
_boolean
(
opts
.
emptySelectionClipboard
,
defaults
.
emptySelectionClipboard
),
useTabStops
:
_boolean
(
opts
.
useTabStops
,
defaults
.
useTabStops
),
performanceCritical
:
performanceCritical
,
viewInfo
:
viewInfo
,
contribInfo
:
contribInfo
,
};
...
...
@@ -1514,7 +1517,7 @@ export class EditorOptionsValidator {
};
}
private
static
_sanitizeContribInfo
(
opts
:
IEditorOptions
,
defaults
:
EditorContribOptions
):
EditorContribOptions
{
private
static
_sanitizeContribInfo
(
opts
:
IEditorOptions
,
defaults
:
EditorContribOptions
,
performanceCritical
:
boolean
):
EditorContribOptions
{
let
quickSuggestions
:
boolean
|
{
other
:
boolean
,
comments
:
boolean
,
strings
:
boolean
};
if
(
typeof
opts
.
quickSuggestions
===
'
object
'
)
{
quickSuggestions
=
{
other
:
true
,
...
opts
.
quickSuggestions
};
...
...
@@ -1538,12 +1541,12 @@ export class EditorOptionsValidator {
wordBasedSuggestions
:
_boolean
(
opts
.
wordBasedSuggestions
,
defaults
.
wordBasedSuggestions
),
suggestFontSize
:
_clampedInt
(
opts
.
suggestFontSize
,
defaults
.
suggestFontSize
,
0
,
1000
),
suggestLineHeight
:
_clampedInt
(
opts
.
suggestLineHeight
,
defaults
.
suggestLineHeight
,
0
,
1000
),
selectionHighlight
:
_boolean
(
opts
.
selectionHighlight
,
defaults
.
selectionHighlight
),
occurrencesHighlight
:
_boolean
(
opts
.
occurrencesHighlight
,
defaults
.
occurrencesHighlight
),
codeLens
:
_boolean
(
opts
.
codeLens
,
defaults
.
codeLens
)
&&
_boolean
(
opts
.
referenceInfos
,
true
),
folding
:
_boolean
(
opts
.
folding
,
defaults
.
folding
),
selectionHighlight
:
!
performanceCritical
&&
_boolean
(
opts
.
selectionHighlight
,
defaults
.
selectionHighlight
),
occurrencesHighlight
:
!
performanceCritical
&&
_boolean
(
opts
.
occurrencesHighlight
,
defaults
.
occurrencesHighlight
),
codeLens
:
!
performanceCritical
&&
_boolean
(
opts
.
codeLens
,
defaults
.
codeLens
)
&&
_boolean
(
opts
.
referenceInfos
,
true
),
folding
:
!
performanceCritical
&&
_boolean
(
opts
.
folding
,
defaults
.
folding
),
showFoldingControls
:
_stringSet
<
'
always
'
|
'
mouseover
'
>
(
opts
.
showFoldingControls
,
defaults
.
showFoldingControls
,
[
'
always
'
,
'
mouseover
'
]),
matchBrackets
:
_boolean
(
opts
.
matchBrackets
,
defaults
.
matchBrackets
),
matchBrackets
:
!
performanceCritical
&&
_boolean
(
opts
.
matchBrackets
,
defaults
.
matchBrackets
),
};
}
}
...
...
@@ -1879,6 +1882,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
dragAndDrop
:
false
,
emptySelectionClipboard
:
true
,
useTabStops
:
true
,
performanceCritical
:
false
,
viewInfo
:
{
extraEditorClassName
:
''
,
...
...
src/vs/editor/contrib/bracketMatching/common/bracketMatching.ts
浏览文件 @
340110ff
...
...
@@ -82,7 +82,16 @@ export class BracketMatchingController extends Disposable implements editorCommo
this
.
_matchBrackets
=
this
.
_editor
.
getConfiguration
().
contribInfo
.
matchBrackets
;
this
.
_updateBracketsSoon
.
schedule
();
this
.
_register
(
editor
.
onDidChangeCursorPosition
((
e
)
=>
this
.
_updateBracketsSoon
.
schedule
()));
this
.
_register
(
editor
.
onDidChangeCursorPosition
((
e
)
=>
{
if
(
!
this
.
_matchBrackets
)
{
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
return
;
}
this
.
_updateBracketsSoon
.
schedule
();
}));
this
.
_register
(
editor
.
onDidChangeModel
((
e
)
=>
{
this
.
_decorations
=
[];
this
.
_updateBracketsSoon
.
schedule
();
}));
this
.
_register
(
editor
.
onDidChangeConfiguration
((
e
)
=>
{
this
.
_matchBrackets
=
this
.
_editor
.
getConfiguration
().
contribInfo
.
matchBrackets
;
...
...
src/vs/editor/contrib/find/common/findController.ts
浏览文件 @
340110ff
...
...
@@ -928,6 +928,7 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd
private
static
ID
=
'
editor.contrib.selectionHighlighter
'
;
private
editor
:
editorCommon
.
ICommonCodeEditor
;
private
_isEnabled
:
boolean
;
private
decorations
:
string
[];
private
updateSoon
:
RunOnceScheduler
;
private
state
:
SelectionHighlighterState
;
...
...
@@ -935,11 +936,22 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd
constructor
(
editor
:
editorCommon
.
ICommonCodeEditor
)
{
super
();
this
.
editor
=
editor
;
this
.
_isEnabled
=
editor
.
getConfiguration
().
contribInfo
.
selectionHighlight
;
this
.
decorations
=
[];
this
.
updateSoon
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
_update
(),
300
));
this
.
state
=
null
;
this
.
_register
(
editor
.
onDidChangeConfiguration
((
e
)
=>
{
this
.
_isEnabled
=
editor
.
getConfiguration
().
contribInfo
.
selectionHighlight
;
}));
this
.
_register
(
editor
.
onDidChangeCursorSelection
((
e
:
ICursorSelectionChangedEvent
)
=>
{
if
(
!
this
.
_isEnabled
)
{
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
return
;
}
if
(
e
.
selection
.
isEmpty
())
{
if
(
e
.
reason
===
CursorChangeReason
.
Explicit
)
{
if
(
this
.
state
&&
(
!
this
.
state
.
lastWordUnderCursor
||
!
this
.
state
.
lastWordUnderCursor
.
containsPosition
(
e
.
selection
.
getStartPosition
())))
{
...
...
@@ -968,10 +980,10 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd
}
private
_update
():
void
{
this
.
_setState
(
SelectionHighlighter
.
_createState
(
this
.
editor
));
this
.
_setState
(
SelectionHighlighter
.
_createState
(
this
.
_isEnabled
,
this
.
editor
));
}
private
static
_createState
(
editor
:
editorCommon
.
ICommonCodeEditor
):
SelectionHighlighterState
{
private
static
_createState
(
isEnabled
:
boolean
,
editor
:
editorCommon
.
ICommonCodeEditor
):
SelectionHighlighterState
{
const
model
=
editor
.
getModel
();
if
(
!
model
)
{
return
null
;
...
...
@@ -980,7 +992,7 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd
const
config
=
editor
.
getConfiguration
();
let
lastWordUnderCursor
:
Selection
=
null
;
if
(
!
config
.
contribInfo
.
selectionHighlight
)
{
if
(
!
isEnabled
)
{
return
null
;
}
...
...
src/vs/editor/contrib/folding/browser/folding.ts
浏览文件 @
340110ff
...
...
@@ -219,7 +219,16 @@ export class FoldingController implements IFoldingController {
this
.
localToDispose
.
push
(
this
.
cursorChangedScheduler
);
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeModelContent
(
e
=>
this
.
contentChangedScheduler
.
schedule
()));
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeCursorPosition
(
e
=>
this
.
cursorChangedScheduler
.
schedule
()));
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeCursorPosition
((
e
)
=>
{
if
(
!
this
.
_isEnabled
)
{
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
return
;
}
this
.
cursorChangedScheduler
.
schedule
();
}));
this
.
localToDispose
.
push
(
this
.
editor
.
onMouseDown
(
e
=>
this
.
onEditorMouseDown
(
e
)));
this
.
localToDispose
.
push
(
this
.
editor
.
onMouseUp
(
e
=>
this
.
onEditorMouseUp
(
e
)));
...
...
src/vs/editor/contrib/suggest/browser/suggestModel.ts
浏览文件 @
340110ff
...
...
@@ -248,6 +248,12 @@ export class SuggestModel implements IDisposable {
||
e
.
source
!==
'
keyboard
'
||
e
.
reason
!==
CursorChangeReason
.
NotSet
)
{
if
(
this
.
_state
===
State
.
Idle
)
{
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
return
;
}
this
.
cancel
();
return
;
}
...
...
src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts
浏览文件 @
340110ff
...
...
@@ -78,6 +78,13 @@ class WordHighlighter {
this
.
model
=
this
.
editor
.
getModel
();
this
.
toUnhook
=
[];
this
.
toUnhook
.
push
(
editor
.
onDidChangeCursorPosition
((
e
:
ICursorPositionChangedEvent
)
=>
{
if
(
!
this
.
occurrencesHighlight
)
{
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
return
;
}
this
.
_onPositionChanged
(
e
);
}));
this
.
toUnhook
.
push
(
editor
.
onDidChangeModel
((
e
)
=>
{
...
...
src/vs/workbench/services/history/browser/history.ts
浏览文件 @
340110ff
...
...
@@ -61,10 +61,10 @@ export class EditorState {
return
true
;
// always let API source win (e.g. "Go to definition" should add a history entry)
}
const
liftedSelection
=
Selection
.
liftSelection
(
this
.
_selection
);
const
liftedOtherSelection
=
Selection
.
liftSelection
(
other
.
_selection
);
const
myLineNumber
=
Math
.
min
(
this
.
_selection
.
selectionStartLineNumber
,
this
.
_selection
.
positionLineNumber
);
const
otherLineNumber
=
Math
.
min
(
other
.
_selection
.
selectionStartLineNumber
,
other
.
_selection
.
positionLineNumber
);
if
(
Math
.
abs
(
liftedSelection
.
getStartPosition
().
lineNumber
-
liftedOtherSelection
.
getStartPosition
().
l
ineNumber
)
<
EditorState
.
EDITOR_SELECTION_THRESHOLD
)
{
if
(
Math
.
abs
(
myLineNumber
-
otherL
ineNumber
)
<
EditorState
.
EDITOR_SELECTION_THRESHOLD
)
{
return
false
;
// ignore selection changes in the range of EditorState.EDITOR_SELECTION_THRESHOLD lines
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录