Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
330d9a77
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,体验更适合开发者的 AI 搜索 >>
提交
330d9a77
编写于
1月 23, 2020
作者:
J
Jackson Kearl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP to show ts assertion failure
上级
ead3e237
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
43 deletion
+37
-43
src/vs/workbench/contrib/search/browser/searchEditor.ts
src/vs/workbench/contrib/search/browser/searchEditor.ts
+37
-43
未找到文件。
src/vs/workbench/contrib/search/browser/searchEditor.ts
浏览文件 @
330d9a77
...
...
@@ -87,16 +87,48 @@ export class SearchEditor extends BaseEditor {
createEditor
(
parent
:
HTMLElement
)
{
DOM
.
addClass
(
parent
,
'
search-editor
'
);
// Query
this
.
queryEditorContainer
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
.query-container
'
));
this
.
createQueryEditor
(
parent
);
// Editor
const
searchResultContainer
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
.search-results
'
));
const
configuration
:
IEditorOptions
=
this
.
configurationService
.
getValue
(
'
editor
'
,
{
overrideIdentifier
:
'
search-result
'
});
const
options
:
ICodeEditorWidgetOptions
=
{};
this
.
searchResultEditor
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
CodeEditorWidget
,
searchResultContainer
,
configuration
,
options
));
this
.
searchResultEditor
.
onMouseUp
(
e
=>
{
if
(
e
.
event
.
detail
===
2
)
{
const
behaviour
=
this
.
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
).
searchEditorPreview
.
doubleClickBehaviour
;
const
position
=
e
.
target
.
position
;
if
(
position
&&
behaviour
!==
'
selectWord
'
)
{
const
line
=
this
.
searchResultEditor
.
getModel
()?.
getLineContent
(
position
.
lineNumber
)
??
''
;
if
(
line
.
match
(
RESULT_LINE_REGEX
))
{
this
.
searchResultEditor
.
setSelection
(
Range
.
fromPositions
(
position
));
this
.
commandService
.
executeCommand
(
behaviour
===
'
goToLocation
'
?
'
editor.action.goToDeclaration
'
:
'
editor.action.openDeclarationToTheSide
'
);
}
}
}
});
this
.
_register
(
this
.
searchResultEditor
.
onKeyDown
(
e
=>
e
.
keyCode
===
KeyCode
.
Escape
&&
this
.
queryEditorWidget
.
searchInput
.
focus
()));
this
.
_register
(
this
.
searchResultEditor
.
onDidChangeModel
(()
=>
this
.
hideHeader
()));
this
.
_register
(
this
.
searchResultEditor
.
onDidChangeModelContent
(()
=>
(
this
.
_input
as
SearchEditorInput
)?.
setDirty
(
true
)));
[
this
.
queryEditorWidget
.
searchInputFocusTracker
,
this
.
queryEditorWidget
.
replaceInputFocusTracker
,
this
.
inputPatternExcludes
.
inputFocusTracker
,
this
.
inputPatternIncludes
.
inputFocusTracker
]
.
map
(
tracker
=>
{
this
.
_register
(
tracker
.
onDidFocus
(()
=>
setTimeout
(()
=>
this
.
inputFocusContextKey
.
set
(
true
),
0
)));
this
.
_register
(
tracker
.
onDidBlur
(()
=>
this
.
inputFocusContextKey
.
set
(
false
)));
});
}
private
createQueryEditor
(
parent
:
HTMLElement
)
{
this
.
queryEditorContainer
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
.query-container
'
));
this
.
queryEditorWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SearchWidget
,
this
.
queryEditorContainer
,
{
_hideReplaceToggle
:
true
,
showContextToggle
:
true
}));
this
.
_register
(
this
.
queryEditorWidget
.
onReplaceToggled
(()
=>
this
.
reLayout
()));
this
.
_register
(
this
.
queryEditorWidget
.
onDidHeightChange
(()
=>
this
.
reLayout
()));
this
.
queryEditorWidget
.
onSearchSubmit
(()
=>
this
.
runSearch
(
true
));
// onSearchSubmit has an internal delayer, so skip over ours.
this
.
queryEditorWidget
.
searchInput
.
onDidOptionChange
(()
=>
this
.
runSearch
());
this
.
queryEditorWidget
.
onDidToggleContext
(()
=>
this
.
runSearch
());
// Includes/Excludes Dropdown
this
.
includesExcludesContainer
=
DOM
.
append
(
this
.
queryEditorContainer
,
DOM
.
$
(
'
.includes-excludes
'
));
// // Toggle query details button
...
...
@@ -107,7 +139,6 @@ export class SearchEditor extends BaseEditor {
}));
this
.
_register
(
DOM
.
addDisposableListener
(
this
.
toggleQueryDetailsButton
,
DOM
.
EventType
.
KEY_UP
,
(
e
:
KeyboardEvent
)
=>
{
const
event
=
new
StandardKeyboardEvent
(
e
);
if
(
event
.
equals
(
KeyCode
.
Enter
)
||
event
.
equals
(
KeyCode
.
Space
))
{
DOM
.
EventHelper
.
stop
(
e
);
this
.
toggleIncludesExcludes
();
...
...
@@ -115,70 +146,33 @@ export class SearchEditor extends BaseEditor {
}));
this
.
_register
(
DOM
.
addDisposableListener
(
this
.
toggleQueryDetailsButton
,
DOM
.
EventType
.
KEY_DOWN
,
(
e
:
KeyboardEvent
)
=>
{
const
event
=
new
StandardKeyboardEvent
(
e
);
if
(
event
.
equals
(
KeyMod
.
Shift
|
KeyCode
.
Tab
))
{
if
(
this
.
queryEditorWidget
.
isReplaceActive
())
{
this
.
queryEditorWidget
.
focusReplaceAllAction
();
}
else
{
}
else
{
this
.
queryEditorWidget
.
isReplaceShown
()
?
this
.
queryEditorWidget
.
replaceInput
.
focusOnPreserve
()
:
this
.
queryEditorWidget
.
focusRegexAction
();
}
DOM
.
EventHelper
.
stop
(
e
);
}
}));
// // Includes
const
folderIncludesList
=
DOM
.
append
(
this
.
includesExcludesContainer
,
DOM
.
$
(
'
.file-types.includes
'
));
const
filesToIncludeTitle
=
localize
(
'
searchScope.includes
'
,
"
files to include
"
);
DOM
.
append
(
folderIncludesList
,
DOM
.
$
(
'
h4
'
,
undefined
,
filesToIncludeTitle
));
this
.
inputPatternIncludes
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
PatternInputWidget
,
folderIncludesList
,
this
.
contextViewService
,
{
ariaLabel
:
localize
(
'
label.includes
'
,
'
Search Include Patterns
'
),
}));
this
.
inputPatternIncludes
.
onSubmit
(
_triggeredOnType
=>
this
.
runSearch
());
// // Excludes
const
excludesList
=
DOM
.
append
(
this
.
includesExcludesContainer
,
DOM
.
$
(
'
.file-types.excludes
'
));
const
excludesTitle
=
localize
(
'
searchScope.excludes
'
,
"
files to exclude
"
);
DOM
.
append
(
excludesList
,
DOM
.
$
(
'
h4
'
,
undefined
,
excludesTitle
));
this
.
inputPatternExcludes
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
ExcludePatternInputWidget
,
excludesList
,
this
.
contextViewService
,
{
ariaLabel
:
localize
(
'
label.excludes
'
,
'
Search Exclude Patterns
'
),
}));
this
.
inputPatternExcludes
.
onSubmit
(
_triggeredOnType
=>
this
.
runSearch
());
this
.
inputPatternExcludes
.
onChangeIgnoreBox
(()
=>
this
.
runSearch
());
// Editor
const
searchResultContainer
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
.search-results
'
));
const
configuration
:
IEditorOptions
=
this
.
configurationService
.
getValue
(
'
editor
'
,
{
overrideIdentifier
:
'
search-result
'
});
const
options
:
ICodeEditorWidgetOptions
=
{};
this
.
searchResultEditor
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
CodeEditorWidget
,
searchResultContainer
,
configuration
,
options
));
this
.
searchResultEditor
.
onMouseUp
(
e
=>
{
if
(
e
.
event
.
detail
===
2
)
{
const
behaviour
=
this
.
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
).
searchEditorPreview
.
doubleClickBehaviour
;
const
position
=
e
.
target
.
position
;
if
(
position
&&
behaviour
!==
'
selectWord
'
)
{
const
line
=
this
.
searchResultEditor
.
getModel
()?.
getLineContent
(
position
.
lineNumber
)
??
''
;
if
(
line
.
match
(
RESULT_LINE_REGEX
))
{
this
.
searchResultEditor
.
setSelection
(
Range
.
fromPositions
(
position
));
this
.
commandService
.
executeCommand
(
behaviour
===
'
goToLocation
'
?
'
editor.action.goToDeclaration
'
:
'
editor.action.openDeclarationToTheSide
'
);
}
}
}
});
this
.
_register
(
this
.
searchResultEditor
.
onKeyDown
(
e
=>
e
.
keyCode
===
KeyCode
.
Escape
&&
this
.
queryEditorWidget
.
searchInput
.
focus
()));
this
.
_register
(
this
.
searchResultEditor
.
onDidChangeModel
(()
=>
this
.
hideHeader
()));
this
.
_register
(
this
.
searchResultEditor
.
onDidChangeModelContent
(()
=>
(
this
.
_input
as
SearchEditorInput
)?.
setDirty
(
true
)));
[
this
.
queryEditorWidget
.
searchInputFocusTracker
,
this
.
queryEditorWidget
.
replaceInputFocusTracker
,
this
.
inputPatternExcludes
.
inputFocusTracker
,
this
.
inputPatternIncludes
.
inputFocusTracker
]
.
map
(
tracker
=>
{
this
.
_register
(
tracker
.
onDidFocus
(()
=>
setTimeout
(()
=>
this
.
inputFocusContextKey
.
set
(
true
),
0
)));
this
.
_register
(
tracker
.
onDidBlur
(()
=>
this
.
inputFocusContextKey
.
set
(
false
)));
});
}
focusNextInput
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录