Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
571ad349
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,发现更多精彩内容 >>
提交
571ad349
编写于
2月 11, 2020
作者:
J
Jackson Kearl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Inherit from BaseTextEditor.
Closes #90326 Closes #90325
上级
6f1de79b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
52 addition
and
56 deletion
+52
-56
src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
...vs/workbench/contrib/searchEditor/browser/searchEditor.ts
+52
-56
未找到文件。
src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
浏览文件 @
571ad349
...
@@ -11,15 +11,13 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
...
@@ -11,15 +11,13 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
'
vs/css!./media/searchEditor
'
;
import
'
vs/css!./media/searchEditor
'
;
import
{
CodeEditorWidget
,
ICodeEditorWidgetOptions
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
import
{
CodeEditorWidget
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
import
type
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
TrackedRangeStickiness
}
from
'
vs/editor/common/model
'
;
import
{
TrackedRangeStickiness
}
from
'
vs/editor/common/model
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ReferencesController
}
from
'
vs/editor/contrib/gotoSymbol/peek/referencesController
'
;
import
{
ReferencesController
}
from
'
vs/editor/contrib/gotoSymbol/peek/referencesController
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
@@ -31,8 +29,7 @@ import { inputBorder, registerColor, searchEditorFindMatch, searchEditorFindMatc
...
@@ -31,8 +29,7 @@ import { inputBorder, registerColor, searchEditorFindMatch, searchEditorFindMatc
import
{
attachInputBoxStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
attachInputBoxStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IThemeService
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorOptions
,
IEditorMemento
}
from
'
vs/workbench/common/editor
'
;
import
{
ExcludePatternInputWidget
,
PatternInputWidget
}
from
'
vs/workbench/contrib/search/browser/patternInputWidget
'
;
import
{
ExcludePatternInputWidget
,
PatternInputWidget
}
from
'
vs/workbench/contrib/search/browser/patternInputWidget
'
;
import
{
SearchWidget
}
from
'
vs/workbench/contrib/search/browser/searchWidget
'
;
import
{
SearchWidget
}
from
'
vs/workbench/contrib/search/browser/searchWidget
'
;
import
{
InputBoxFocusedKey
}
from
'
vs/workbench/contrib/search/common/constants
'
;
import
{
InputBoxFocusedKey
}
from
'
vs/workbench/contrib/search/common/constants
'
;
...
@@ -46,19 +43,21 @@ import { IPatternInfo, ISearchConfigurationProperties, ITextQuery } from 'vs/wor
...
@@ -46,19 +43,21 @@ import { IPatternInfo, ISearchConfigurationProperties, ITextQuery } from 'vs/wor
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ICodeEditorViewState
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorViewState
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
assertIsDefined
}
from
'
vs/base/common/types
'
;
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/textResourceConfigurationService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
const
RESULT_LINE_REGEX
=
/^
(\s
+
)(\d
+
)(
:|
)(\s
+
)(
.*
)
$/
;
const
RESULT_LINE_REGEX
=
/^
(\s
+
)(\d
+
)(
:|
)(\s
+
)(
.*
)
$/
;
const
FILE_LINE_REGEX
=
/^
(\S
.*
)
:$/
;
const
FILE_LINE_REGEX
=
/^
(\S
.*
)
:$/
;
type
SearchEditorViewState
=
type
SearchEditorViewState
=
ICodeEditorViewState
&
{
focused
:
'
input
'
|
'
editor
'
};
|
{
focused
:
'
input
'
}
|
{
focused
:
'
editor
'
,
state
:
ICodeEditorViewState
};
export
class
SearchEditor
extends
BaseEditor
{
export
class
SearchEditor
extends
Base
Text
Editor
{
static
readonly
ID
:
string
=
'
workbench.editor.searchEditor
'
;
static
readonly
ID
:
string
=
'
workbench.editor.searchEditor
'
;
static
readonly
TEXT
_EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
searchEditorViewState
'
;
static
readonly
SEARCH
_EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
searchEditorViewState
'
;
private
queryEditorWidget
!
:
SearchWidget
;
private
queryEditorWidget
!
:
SearchWidget
;
private
searchResultEditor
!
:
CodeEditorWidget
;
private
searchResultEditor
!
:
CodeEditorWidget
;
...
@@ -80,8 +79,6 @@ export class SearchEditor extends BaseEditor {
...
@@ -80,8 +79,6 @@ export class SearchEditor extends BaseEditor {
private
messageDisposables
:
IDisposable
[]
=
[];
private
messageDisposables
:
IDisposable
[]
=
[];
private
container
:
HTMLElement
;
private
container
:
HTMLElement
;
private
editorMemento
:
IEditorMemento
<
SearchEditorViewState
>
;
constructor
(
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IThemeService
themeService
:
IThemeService
,
@
IThemeService
themeService
:
IThemeService
,
...
@@ -89,18 +86,19 @@ export class SearchEditor extends BaseEditor {
...
@@ -89,18 +86,19 @@ export class SearchEditor extends BaseEditor {
@
IModelService
private
readonly
modelService
:
IModelService
,
@
IModelService
private
readonly
modelService
:
IModelService
,
@
IWorkspaceContextService
private
readonly
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
readonly
contextService
:
IWorkspaceContextService
,
@
ILabelService
private
readonly
labelService
:
ILabelService
,
@
ILabelService
private
readonly
labelService
:
ILabelService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
@
IInstantiationService
readonly
instantiationService
:
IInstantiationService
,
@
IInstantiationService
readonly
instantiationService
:
IInstantiationService
,
@
IContextViewService
private
readonly
contextViewService
:
IContextViewService
,
@
IContextViewService
private
readonly
contextViewService
:
IContextViewService
,
@
ICommandService
private
readonly
commandService
:
ICommandService
,
@
ICommandService
private
readonly
commandService
:
ICommandService
,
@
IContextKeyService
readonly
contextKeyService
:
IContextKeyService
,
@
IContextKeyService
readonly
contextKeyService
:
IContextKeyService
,
@
IEditorProgressService
readonly
progressService
:
IEditorProgressService
,
@
IEditorProgressService
readonly
progressService
:
IEditorProgressService
,
@
IEditorGroupsService
protected
editorGroupService
:
IEditorGroupsService
@
ITextResourceConfigurationService
textResourceService
:
ITextResourceConfigurationService
,
@
IEditorGroupsService
protected
editorGroupService
:
IEditorGroupsService
,
@
IEditorService
protected
editorService
:
IEditorService
,
@
IConfigurationService
protected
configurationService
:
IConfigurationService
,
)
{
)
{
super
(
SearchEditor
.
ID
,
telemetryService
,
themeService
,
storage
Service
);
super
(
SearchEditor
.
ID
,
telemetryService
,
instantiationService
,
storageService
,
textResourceService
,
themeService
,
editorService
,
editorGroup
Service
);
this
.
container
=
DOM
.
$
(
'
.search-editor
'
);
this
.
container
=
DOM
.
$
(
'
.search-editor
'
);
this
.
editorMemento
=
this
.
getEditorMemento
<
SearchEditorViewState
>
(
editorGroupService
,
SearchEditor
.
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
,
100
);
const
scopedContextKeyService
=
contextKeyService
.
createScoped
(
this
.
container
);
const
scopedContextKeyService
=
contextKeyService
.
createScoped
(
this
.
container
);
this
.
instantiationService
=
instantiationService
.
createChild
(
new
ServiceCollection
([
IContextKeyService
,
scopedContextKeyService
]));
this
.
instantiationService
=
instantiationService
.
createChild
(
new
ServiceCollection
([
IContextKeyService
,
scopedContextKeyService
]));
...
@@ -200,18 +198,9 @@ export class SearchEditor extends BaseEditor {
...
@@ -200,18 +198,9 @@ export class SearchEditor extends BaseEditor {
private
createResultsEditor
(
parent
:
HTMLElement
)
{
private
createResultsEditor
(
parent
:
HTMLElement
)
{
const
searchResultContainer
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
.search-results
'
));
const
searchResultContainer
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
.search-results
'
));
const
getSearchEditorOptions
=
()
=>
this
.
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
,
{
overrideIdentifier
:
'
search-result
'
});
super
.
createEditor
(
searchResultContainer
);
const
configuration
:
IEditorOptions
=
getSearchEditorOptions
();
this
.
searchResultEditor
=
super
.
getControl
()
as
CodeEditorWidget
;
this
.
_register
(
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
if
(
e
.
affectsConfiguration
(
'
editor
'
))
{
this
.
searchResultEditor
.
updateOptions
(
getSearchEditorOptions
());
}
}));
const
options
:
ICodeEditorWidgetOptions
=
{};
this
.
searchResultEditor
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
CodeEditorWidget
,
searchResultContainer
,
configuration
,
options
));
this
.
searchResultEditor
.
onMouseUp
(
e
=>
{
this
.
searchResultEditor
.
onMouseUp
(
e
=>
{
if
(
e
.
event
.
detail
===
2
)
{
if
(
e
.
event
.
detail
===
2
)
{
const
behaviour
=
this
.
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
).
searchEditorPreview
.
doubleClickBehaviour
;
const
behaviour
=
this
.
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
).
searchEditorPreview
.
doubleClickBehaviour
;
const
position
=
e
.
target
.
position
;
const
position
=
e
.
target
.
position
;
...
@@ -316,16 +305,8 @@ export class SearchEditor extends BaseEditor {
...
@@ -316,16 +305,8 @@ export class SearchEditor extends BaseEditor {
}
}
}
}
private
async
doRunSearch
()
{
private
readConfigFromWidget
()
{
const
startInput
=
this
.
input
;
return
{
this
.
searchHistoryDelayer
.
trigger
(()
=>
{
this
.
queryEditorWidget
.
searchInput
.
onSearchSubmit
();
this
.
inputPatternExcludes
.
onSearchSubmit
();
this
.
inputPatternIncludes
.
onSearchSubmit
();
});
const
config
:
SearchConfiguration
=
{
caseSensitive
:
this
.
queryEditorWidget
.
searchInput
.
getCaseSensitive
(),
caseSensitive
:
this
.
queryEditorWidget
.
searchInput
.
getCaseSensitive
(),
contextLines
:
this
.
queryEditorWidget
.
contextLines
(),
contextLines
:
this
.
queryEditorWidget
.
contextLines
(),
excludes
:
this
.
inputPatternExcludes
.
getValue
(),
excludes
:
this
.
inputPatternExcludes
.
getValue
(),
...
@@ -336,6 +317,18 @@ export class SearchEditor extends BaseEditor {
...
@@ -336,6 +317,18 @@ export class SearchEditor extends BaseEditor {
useIgnores
:
this
.
inputPatternExcludes
.
useExcludesAndIgnoreFiles
(),
useIgnores
:
this
.
inputPatternExcludes
.
useExcludesAndIgnoreFiles
(),
showIncludesExcludes
:
this
.
showingIncludesExcludes
showIncludesExcludes
:
this
.
showingIncludesExcludes
};
};
}
private
async
doRunSearch
()
{
const
startInput
=
this
.
getInput
();
this
.
searchHistoryDelayer
.
trigger
(()
=>
{
this
.
queryEditorWidget
.
searchInput
.
onSearchSubmit
();
this
.
inputPatternExcludes
.
onSearchSubmit
();
this
.
inputPatternIncludes
.
onSearchSubmit
();
});
const
config
:
SearchConfiguration
=
this
.
readConfigFromWidget
();
if
(
!
config
.
query
)
{
return
;
}
if
(
!
config
.
query
)
{
return
;
}
...
@@ -377,7 +370,10 @@ export class SearchEditor extends BaseEditor {
...
@@ -377,7 +370,10 @@ export class SearchEditor extends BaseEditor {
this
.
searchOperation
.
start
(
500
);
this
.
searchOperation
.
start
(
500
);
await
searchModel
.
search
(
query
).
finally
(()
=>
this
.
searchOperation
.
stop
());
await
searchModel
.
search
(
query
).
finally
(()
=>
this
.
searchOperation
.
stop
());
const
input
=
this
.
getInput
();
const
input
=
this
.
getInput
();
if
(
!
input
||
input
!==
startInput
)
{
if
(
!
input
||
input
!==
startInput
||
JSON
.
stringify
(
config
)
!==
JSON
.
stringify
(
this
.
readConfigFromWidget
()))
{
searchModel
.
dispose
();
searchModel
.
dispose
();
return
;
return
;
}
}
...
@@ -473,32 +469,28 @@ export class SearchEditor extends BaseEditor {
...
@@ -473,32 +469,28 @@ export class SearchEditor extends BaseEditor {
}
}
private
saveViewState
()
{
private
saveViewState
()
{
const
input
=
this
.
getInput
();
const
resource
=
this
.
getInput
()?.
resource
;
const
group
=
this
.
group
;
if
(
resource
)
{
this
.
saveTextEditorViewState
(
resource
);
}
if
(
!
input
||
!
group
)
{
return
;
}
if
(
this
.
searchResultEditor
.
hasWidgetFocus
())
{
const
viewState
=
this
.
searchResultEditor
.
saveViewState
();
if
(
viewState
)
{
this
.
editorMemento
.
saveEditorState
(
group
,
input
.
resource
,
{
focused
:
'
editor
'
,
state
:
viewState
});
}
}
else
{
this
.
editorMemento
.
saveEditorState
(
group
,
input
.
resource
,
{
focused
:
'
input
'
});
}
}
protected
retrieveTextEditorViewState
(
resource
:
URI
):
SearchEditorViewState
|
null
{
const
control
=
this
.
getControl
();
const
editorViewState
=
control
.
saveViewState
();
if
(
!
editorViewState
)
{
return
null
;
}
if
(
resource
.
toString
()
!==
this
.
getInput
()?.
resource
.
toString
())
{
return
null
;
}
return
{
...
editorViewState
,
focused
:
this
.
searchResultEditor
.
hasWidgetFocus
()
?
'
editor
'
:
'
input
'
};
}
}
private
loadViewState
()
{
private
loadViewState
()
{
const
group
=
this
.
group
;
const
resource
=
assertIsDefined
(
this
.
input
?.
getResource
());
const
input
=
this
.
getInput
();
return
this
.
loadTextEditorViewState
(
resource
)
as
SearchEditorViewState
;
if
(
!
input
||
!
group
)
{
return
;
}
return
this
.
editorMemento
.
loadEditorState
(
group
,
input
.
resource
);
}
}
private
restoreViewState
()
{
private
restoreViewState
()
{
const
viewState
=
this
.
loadViewState
();
const
viewState
=
this
.
loadViewState
();
if
(
viewState
)
{
this
.
searchResultEditor
.
restoreViewState
(
viewState
);
}
if
(
viewState
&&
viewState
.
focused
===
'
editor
'
)
{
if
(
viewState
&&
viewState
.
focused
===
'
editor
'
)
{
this
.
searchResultEditor
.
restoreViewState
(
viewState
.
state
);
this
.
searchResultEditor
.
focus
();
this
.
searchResultEditor
.
focus
();
}
else
{
}
else
{
this
.
queryEditorWidget
.
focus
();
this
.
queryEditorWidget
.
focus
();
...
@@ -509,6 +501,10 @@ export class SearchEditor extends BaseEditor {
...
@@ -509,6 +501,10 @@ export class SearchEditor extends BaseEditor {
this
.
saveViewState
();
this
.
saveViewState
();
super
.
clearInput
();
super
.
clearInput
();
}
}
getAriaLabel
()
{
return
this
.
getInput
()?.
getName
()
??
localize
(
'
searchEditor
'
,
"
Search Editor
"
);
}
}
}
registerThemingParticipant
((
theme
,
collector
)
=>
{
registerThemingParticipant
((
theme
,
collector
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录