Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0447f82d
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,发现更多精彩内容 >>
提交
0447f82d
编写于
12月 10, 2015
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improvements in Find Widget: Ctrl+H always focuses replace, Ctrl+DownArrow focuses the editor
上级
0b90eb2c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
72 deletion
+39
-72
src/vs/editor/contrib/find/browser/find.ts
src/vs/editor/contrib/find/browser/find.ts
+14
-44
src/vs/editor/contrib/find/browser/findWidget.ts
src/vs/editor/contrib/find/browser/findWidget.ts
+21
-8
src/vs/editor/contrib/find/common/findModel.ts
src/vs/editor/contrib/find/common/findModel.ts
+4
-20
未找到文件。
src/vs/editor/contrib/find/browser/find.ts
浏览文件 @
0447f82d
...
...
@@ -34,7 +34,7 @@ export class FindController implements EditorCommon.IEditorContribution, FindWid
private
editor
:
EditorBrowser
.
ICodeEditor
;
private
_findWidgetVisible
:
IKeybindingContextKey
<
boolean
>
;
private
model
:
FindModel
.
IFind
Model
;
private
model
:
FindModel
.
FindModelBoundToEditor
Model
;
private
widget
:
FindWidget
.
FindWidget
;
private
widgetIsVisible
:
boolean
;
private
widgetListeners
:
Lifecycle
.
IDisposable
[];
...
...
@@ -84,10 +84,7 @@ export class FindController implements EditorCommon.IEditorContribution, FindWid
public
dispose
():
void
{
this
.
widgetListeners
=
Lifecycle
.
disposeAll
(
this
.
widgetListeners
);
if
(
this
.
widget
)
{
this
.
widget
.
dispose
();
this
.
widget
=
null
;
}
this
.
widget
.
dispose
();
this
.
disposeBindingAndModel
();
this
.
_eventEmitter
.
dispose
();
}
...
...
@@ -98,9 +95,7 @@ export class FindController implements EditorCommon.IEditorContribution, FindWid
private
disposeBindingAndModel
():
void
{
this
.
_findWidgetVisible
.
reset
();
if
(
this
.
widget
)
{
this
.
widget
.
setModel
(
null
);
}
this
.
widget
.
setModel
(
null
);
if
(
this
.
model
)
{
this
.
model
.
dispose
();
this
.
model
=
null
;
...
...
@@ -113,49 +108,16 @@ export class FindController implements EditorCommon.IEditorContribution, FindWid
this
.
editor
.
focus
();
}
private
_ensureHasState
():
void
{
if
(
!
this
.
lastState
)
{
this
.
lastState
=
{
isReplaceRevealed
:
false
,
properties
:
{
isRegex
:
false
,
matchCase
:
false
,
wholeWord
:
false
},
replaceString
:
''
,
searchString
:
''
};
}
}
public
toggleCaseSensitive
():
void
{
if
(
this
.
widget
)
{
this
.
widget
.
toggleCaseSensitive
();
}
else
{
this
.
_ensureHasState
();
this
.
lastState
.
properties
.
matchCase
=
!
this
.
lastState
.
properties
.
matchCase
;
this
.
_eventEmitter
.
emit
(
FindController
.
_STATE_CHANGED_EVENT
);
}
this
.
widget
.
toggleCaseSensitive
();
}
public
toggleWholeWords
():
void
{
if
(
this
.
widget
)
{
this
.
widget
.
toggleWholeWords
();
}
else
{
this
.
_ensureHasState
();
this
.
lastState
.
properties
.
wholeWord
=
!
this
.
lastState
.
properties
.
wholeWord
;
this
.
_eventEmitter
.
emit
(
FindController
.
_STATE_CHANGED_EVENT
);
}
this
.
widget
.
toggleWholeWords
();
}
public
toggleRegex
():
void
{
if
(
this
.
widget
)
{
this
.
widget
.
toggleRegex
();
}
else
{
this
.
_ensureHasState
();
this
.
lastState
.
properties
.
isRegex
=
!
this
.
lastState
.
properties
.
isRegex
;
this
.
_eventEmitter
.
emit
(
FindController
.
_STATE_CHANGED_EVENT
);
}
this
.
widget
.
toggleRegex
();
}
private
onWidgetClosed
():
void
{
...
...
@@ -225,6 +187,14 @@ export class FindController implements EditorCommon.IEditorContribution, FindWid
// Start searching
this
.
model
.
start
(
this
.
lastState
,
searchScope
,
shouldFocus
);
this
.
widgetIsVisible
=
true
;
if
(
shouldFocus
)
{
if
(
forceRevealReplace
)
{
this
.
widget
.
focusReplaceInput
();
}
else
{
this
.
widget
.
focusFindInput
();
}
}
}
public
startFromAction
(
withReplace
:
boolean
):
void
{
...
...
src/vs/editor/contrib/find/browser/findWidget.ts
浏览文件 @
0447f82d
...
...
@@ -78,7 +78,7 @@ export class FindWidget extends EventEmitter.EventEmitter implements EditorBrows
private
_toDispose
:
Lifecycle
.
IDisposable
[];
private
_model
:
FindModel
.
IFind
Model
;
private
_model
:
FindModel
.
FindModelBoundToEditor
Model
;
private
_modelListenersToDispose
:
Lifecycle
.
IDisposable
[];
private
focusTracker
:
DomUtils
.
IFocusTracker
;
...
...
@@ -186,19 +186,14 @@ export class FindWidget extends EventEmitter.EventEmitter implements EditorBrows
return
result
;
}
public
setModel
(
newFindModel
:
FindModel
.
IFind
Model
):
void
{
public
setModel
(
newFindModel
:
FindModel
.
FindModelBoundToEditor
Model
):
void
{
this
.
_removeModel
();
if
(
newFindModel
)
{
// We have a new model! :)
this
.
_model
=
newFindModel
;
this
.
_modelListenersToDispose
.
push
(
this
.
_model
.
addStartEventListener
((
e
:
FindModel
.
IFindStartEvent
)
=>
{
this
.
_reveal
(
e
.
should
Focus
);
this
.
_reveal
(
e
.
should
Animate
);
this
.
_setState
(
e
.
state
,
e
.
selectionFindEnabled
);
if
(
e
.
shouldFocus
)
{
this
.
_findInput
.
select
();
// Edge browser requires focus() in addition to select()
this
.
_findInput
.
focus
();
}
}));
this
.
_modelListenersToDispose
.
push
(
this
.
_model
.
addMatchesUpdatedEventListener
((
e
:
FindModel
.
IFindMatchesEvent
)
=>
{
DomUtils
.
toggleClass
(
this
.
_domNode
,
'
no-results
'
,
this
.
_findInput
.
getValue
()
!==
''
&&
e
.
count
===
0
);
...
...
@@ -209,6 +204,18 @@ export class FindWidget extends EventEmitter.EventEmitter implements EditorBrows
}
}
public
focusFindInput
():
void
{
this
.
_findInput
.
select
();
// Edge browser requires focus() in addition to select()
this
.
_findInput
.
focus
();
}
public
focusReplaceInput
():
void
{
this
.
_replaceInputBox
.
select
();
// Edge browser requires focus() in addition to select()
this
.
_replaceInputBox
.
focus
();
}
private
_removeModel
():
void
{
if
(
this
.
_model
!==
null
)
{
this
.
_modelListenersToDispose
=
Lifecycle
.
disposeAll
(
this
.
_modelListenersToDispose
);
...
...
@@ -265,6 +272,9 @@ export class FindWidget extends EventEmitter.EventEmitter implements EditorBrows
this
.
_findInput
.
focusOnCaseSensitive
();
}
handled
=
true
;
}
else
if
(
e
.
equals
(
CommonKeybindings
.
CTRLCMD_DOWN_ARROW
))
{
this
.
_codeEditor
.
focus
();
handled
=
true
;
}
if
(
handled
)
{
...
...
@@ -290,6 +300,9 @@ export class FindWidget extends EventEmitter.EventEmitter implements EditorBrows
}
else
if
(
e
.
equals
(
CommonKeybindings
.
TAB
))
{
this
.
_findInput
.
focusOnCaseSensitive
();
handled
=
true
;
}
else
if
(
e
.
equals
(
CommonKeybindings
.
CTRLCMD_DOWN_ARROW
))
{
this
.
_codeEditor
.
focus
();
handled
=
true
;
}
if
(
handled
)
{
...
...
src/vs/editor/contrib/find/common/findModel.ts
浏览文件 @
0447f82d
...
...
@@ -43,26 +43,10 @@ export interface IFindState {
export
interface
IFindStartEvent
{
state
:
IFindState
;
selectionFindEnabled
:
boolean
;
should
Focus
:
boolean
;
should
Animate
:
boolean
;
}
export
interface
IFindModel
{
dispose
():
void
;
start
(
newFindData
:
IFindState
,
findScope
:
EditorCommon
.
IEditorRange
,
shouldFocus
:
boolean
):
void
;
recomputeMatches
(
newFindData
:
IFindState
,
jumpToNextMatch
:
boolean
):
void
;
setFindScope
(
findScope
:
EditorCommon
.
IEditorRange
):
void
;
next
():
void
;
prev
():
void
;
replace
():
void
;
replaceAll
():
void
;
addStartEventListener
(
callback
:(
e
:
IFindStartEvent
)
=>
void
):
Lifecycle
.
IDisposable
;
addMatchesUpdatedEventListener
(
callback
:(
e
:
IFindMatchesEvent
)
=>
void
):
Lifecycle
.
IDisposable
;
}
export
class
FindModelBoundToEditorModel
extends
Events
.
EventEmitter
implements
IFindModel
{
export
class
FindModelBoundToEditorModel
extends
Events
.
EventEmitter
{
private
static
_START_EVENT
=
'
start
'
;
private
static
_MATCHES_UPDATED_EVENT
=
'
matches
'
;
...
...
@@ -282,7 +266,7 @@ export class FindModelBoundToEditorModel extends Events.EventEmitter implements
}
}
public
start
(
newFindData
:
IFindState
,
findScope
:
EditorCommon
.
IEditorRange
,
should
Focus
:
boolean
):
void
{
public
start
(
newFindData
:
IFindState
,
findScope
:
EditorCommon
.
IEditorRange
,
should
Animate
:
boolean
):
void
{
this
.
startPosition
=
this
.
editor
.
getPosition
();
this
.
isRegex
=
newFindData
.
properties
.
isRegex
;
...
...
@@ -297,7 +281,7 @@ export class FindModelBoundToEditorModel extends Events.EventEmitter implements
var
e
:
IFindStartEvent
=
{
state
:
newFindData
,
selectionFindEnabled
:
this
.
hasFindScope
(),
should
Focus
:
shouldFocus
should
Animate
:
shouldAnimate
};
this
.
_emitStartEvent
(
e
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录