Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7a34ec55
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,发现更多精彩内容 >>
提交
7a34ec55
编写于
7月 30, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #102441.
上级
057c1f14
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
127 addition
and
6 deletion
+127
-6
src/vs/editor/browser/editorExtensions.ts
src/vs/editor/browser/editorExtensions.ts
+43
-0
src/vs/editor/contrib/find/findController.ts
src/vs/editor/contrib/find/findController.ts
+7
-5
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindReplaceWidget.ts
...ontrib/codeEditor/browser/find/simpleFindReplaceWidget.ts
+29
-1
src/vs/workbench/contrib/notebook/browser/contrib/find/findController.ts
...h/contrib/notebook/browser/contrib/find/findController.ts
+48
-0
未找到文件。
src/vs/editor/browser/editorExtensions.ts
浏览文件 @
7a34ec55
...
...
@@ -337,6 +337,44 @@ export abstract class EditorAction extends EditorCommand {
public
abstract
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
,
args
:
any
):
void
|
Promise
<
void
>
;
}
export
abstract
class
MultiEditorAction
extends
EditorAction
{
private
readonly
_implementations
:
[
number
,
CommandImplementation
][]
=
[];
constructor
(
opts
:
IActionOptions
)
{
super
(
opts
);
}
public
addImplementation
(
priority
:
number
,
implementation
:
CommandImplementation
):
IDisposable
{
this
.
_implementations
.
push
([
priority
,
implementation
]);
this
.
_implementations
.
sort
((
a
,
b
)
=>
b
[
0
]
-
a
[
0
]);
return
{
dispose
:
()
=>
{
for
(
let
i
=
0
;
i
<
this
.
_implementations
.
length
;
i
++
)
{
if
(
this
.
_implementations
[
i
][
1
]
===
implementation
)
{
this
.
_implementations
.
splice
(
i
,
1
);
return
;
}
}
}
};
}
public
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
,
args
:
any
):
void
|
Promise
<
void
>
{
this
.
reportTelemetry
(
accessor
,
editor
);
for
(
const
impl
of
this
.
_implementations
)
{
if
(
impl
[
1
](
accessor
,
args
))
{
return
;
}
}
return
this
.
run
(
accessor
,
editor
,
args
||
{});
}
public
abstract
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
,
args
:
any
):
void
|
Promise
<
void
>
;
}
//#endregion EditorAction
//#region EditorAction2
...
...
@@ -474,6 +512,11 @@ export function registerEditorAction<T extends EditorAction>(ctor: { new(): T; }
return
action
;
}
export
function
registerMultiEditorAction
<
T
extends
MultiEditorAction
>
(
action
:
T
):
T
{
EditorContributionRegistry
.
INSTANCE
.
registerEditorAction
(
action
);
return
action
;
}
export
function
registerInstantiatedEditorAction
(
editorAction
:
EditorAction
):
void
{
EditorContributionRegistry
.
INSTANCE
.
registerEditorAction
(
editorAction
);
}
...
...
src/vs/editor/contrib/find/findController.ts
浏览文件 @
7a34ec55
...
...
@@ -9,7 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorAction
,
EditorCommand
,
ServicesAccessor
,
registerEditorAction
,
registerEditorCommand
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
EditorAction
,
EditorCommand
,
ServicesAccessor
,
registerEditorAction
,
registerEditorCommand
,
registerEditorContribution
,
MultiEditorAction
,
registerMultiEditorAction
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
CONTEXT_FIND_INPUT_FOCUSED
,
CONTEXT_FIND_WIDGET_VISIBLE
,
FIND_IDS
,
FindModelBoundToEditorModel
,
ToggleCaseSensitiveKeybinding
,
ToggleRegexKeybinding
,
ToggleSearchScopeKeybinding
,
ToggleWholeWordKeybinding
,
CONTEXT_REPLACE_INPUT_FOCUSED
}
from
'
vs/editor/contrib/find/findModel
'
;
...
...
@@ -457,7 +457,7 @@ export class FindController extends CommonFindController implements IFindControl
}
}
export
class
StartFindAction
extends
EditorAction
{
export
class
StartFindAction
extends
Multi
EditorAction
{
constructor
()
{
super
({
...
...
@@ -706,7 +706,7 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
}
}
export
class
StartFindReplaceAction
extends
EditorAction
{
export
class
StartFindReplaceAction
extends
Multi
EditorAction
{
constructor
()
{
super
({
...
...
@@ -769,7 +769,8 @@ export class StartFindReplaceAction extends EditorAction {
registerEditorContribution
(
CommonFindController
.
ID
,
FindController
);
registerEditorAction
(
StartFindAction
);
export
const
EditorStartFindAction
=
new
StartFindAction
();
registerMultiEditorAction
(
EditorStartFindAction
);
registerEditorAction
(
StartFindWithSelectionAction
);
registerEditorAction
(
NextMatchFindAction
);
registerEditorAction
(
NextMatchFindAction2
);
...
...
@@ -777,7 +778,8 @@ registerEditorAction(PreviousMatchFindAction);
registerEditorAction
(
PreviousMatchFindAction2
);
registerEditorAction
(
NextSelectionMatchFindAction
);
registerEditorAction
(
PreviousSelectionMatchFindAction
);
registerEditorAction
(
StartFindReplaceAction
);
export
const
EditorStartFindReplaceAction
=
new
StartFindReplaceAction
();
registerMultiEditorAction
(
EditorStartFindReplaceAction
);
const
FindCommand
=
EditorCommand
.
bindToContribution
<
CommonFindController
>
(
CommonFindController
.
get
);
...
...
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindReplaceWidget.ts
浏览文件 @
7a34ec55
...
...
@@ -43,7 +43,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
private
readonly
prevBtn
:
SimpleButton
;
private
readonly
nextBtn
:
SimpleButton
;
pr
ivate
readonly
_replaceInput
!
:
ReplaceInput
;
pr
otected
readonly
_replaceInput
!
:
ReplaceInput
;
private
readonly
_innerReplaceDomNode
!
:
HTMLElement
;
private
_toggleReplaceBtn
!
:
SimpleButton
;
private
readonly
_replaceInputFocusTracker
!
:
dom
.
IFocusTracker
;
...
...
@@ -372,6 +372,34 @@ export abstract class SimpleFindReplaceWidget extends Widget {
},
0
);
}
public
showWithReplace
(
initialInput
?:
string
,
replaceInput
?:
string
):
void
{
if
(
initialInput
&&
!
this
.
_isVisible
)
{
this
.
_findInput
.
setValue
(
initialInput
);
}
if
(
replaceInput
&&
!
this
.
_isVisible
)
{
this
.
_replaceInput
.
setValue
(
replaceInput
);
}
this
.
_isVisible
=
true
;
this
.
_isReplaceVisible
=
true
;
this
.
_state
.
change
({
isReplaceRevealed
:
this
.
_isReplaceVisible
},
false
);
if
(
this
.
_isReplaceVisible
)
{
this
.
_innerReplaceDomNode
.
style
.
display
=
'
flex
'
;
}
else
{
this
.
_innerReplaceDomNode
.
style
.
display
=
'
none
'
;
}
setTimeout
(()
=>
{
dom
.
addClass
(
this
.
_domNode
,
'
visible
'
);
dom
.
addClass
(
this
.
_domNode
,
'
visible-transition
'
);
this
.
_domNode
.
setAttribute
(
'
aria-hidden
'
,
'
false
'
);
this
.
_updateButtons
();
this
.
_replaceInput
.
focus
();
},
0
);
}
public
hide
():
void
{
if
(
this
.
_isVisible
)
{
dom
.
removeClass
(
this
.
_domNode
,
'
visible-transition
'
);
...
...
src/vs/workbench/contrib/notebook/browser/contrib/find/findController.ts
浏览文件 @
7a34ec55
...
...
@@ -27,6 +27,7 @@ import { getActiveNotebookEditor } from 'vs/workbench/contrib/notebook/browser/c
import
{
FindReplaceState
}
from
'
vs/editor/contrib/find/findState
'
;
import
{
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
EditorStartFindAction
,
EditorStartFindReplaceAction
}
from
'
vs/editor/contrib/find/findController
'
;
const
FIND_HIDE_TRANSITION
=
'
find-hide-transition
'
;
const
FIND_SHOW_TRANSITION
=
'
find-show-transition
'
;
...
...
@@ -285,6 +286,27 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
}
}
replace
(
initialFindInput
?:
string
,
initialReplaceInput
?:
string
)
{
super
.
showWithReplace
(
initialFindInput
,
initialReplaceInput
);
this
.
_replaceInput
.
select
();
if
(
this
.
_showTimeout
===
null
)
{
if
(
this
.
_hideTimeout
!==
null
)
{
window
.
clearTimeout
(
this
.
_hideTimeout
);
this
.
_hideTimeout
=
null
;
this
.
_notebookEditor
.
removeClassName
(
FIND_HIDE_TRANSITION
);
}
this
.
_notebookEditor
.
addClassName
(
FIND_SHOW_TRANSITION
);
this
.
_showTimeout
=
window
.
setTimeout
(()
=>
{
this
.
_notebookEditor
.
removeClassName
(
FIND_SHOW_TRANSITION
);
this
.
_showTimeout
=
null
;
},
200
);
}
else
{
// no op
}
}
hide
()
{
super
.
hide
();
this
.
set
([],
false
);
...
...
@@ -371,3 +393,29 @@ registerAction2(class extends Action2 {
controller
.
show
();
}
});
EditorStartFindAction
.
addImplementation
(
100
,
(
accessor
:
ServicesAccessor
,
args
:
any
)
=>
{
let
editorService
=
accessor
.
get
(
IEditorService
);
let
editor
=
getActiveNotebookEditor
(
editorService
);
if
(
!
editor
)
{
return
false
;
}
const
controller
=
editor
.
getContribution
<
NotebookFindWidget
>
(
NotebookFindWidget
.
id
);
controller
.
show
();
return
true
;
});
EditorStartFindReplaceAction
.
addImplementation
(
100
,
(
accessor
:
ServicesAccessor
,
args
:
any
)
=>
{
let
editorService
=
accessor
.
get
(
IEditorService
);
let
editor
=
getActiveNotebookEditor
(
editorService
);
if
(
!
editor
)
{
return
false
;
}
const
controller
=
editor
.
getContribution
<
NotebookFindWidget
>
(
NotebookFindWidget
.
id
);
controller
.
replace
();
return
true
;
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录