Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
70a9b8b2
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 搜索 >>
提交
70a9b8b2
编写于
4月 09, 2020
作者:
J
Jackson Kearl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add experimental setting to reuse prior search config. Ref #89353.
上级
945ee295
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
51 addition
and
26 deletion
+51
-26
src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.ts
...rkbench/contrib/searchEditor/browser/searchEditorInput.ts
+27
-8
src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.ts
...contrib/searchEditor/browser/searchEditorSerialization.ts
+20
-17
src/vs/workbench/services/search/common/search.ts
src/vs/workbench/services/search/common/search.ts
+4
-1
未找到文件。
src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.ts
浏览文件 @
70a9b8b2
...
...
@@ -14,17 +14,21 @@ import { DefaultEndOfLine, ITextModel, TrackedRangeStickiness } from 'vs/editor/
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IFileDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
EditorInput
,
GroupIdentifier
,
IEditorInput
,
IMoveResult
,
IRevertOptions
,
ISaveOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
Memento
}
from
'
vs/workbench/common/memento
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/contrib/files/common/editors/fileEditorInput
'
;
import
{
SearchEditorFindMatchClass
,
SearchEditorScheme
}
from
'
vs/workbench/contrib/searchEditor/browser/constants
'
;
import
{
extractSearchQueryFromModel
,
parseSavedSearchEditor
,
serializeSearchConfiguration
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorSerialization
'
;
import
{
defaultSearchConfig
,
extractSearchQueryFromModel
,
parseSavedSearchEditor
,
serializeSearchConfiguration
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorSerialization
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
AutoSaveMode
,
IFilesConfigurationService
}
from
'
vs/workbench/services/filesConfiguration/common/filesConfigurationService
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
import
{
ISearchConfigurationProperties
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ITextFileSaveOptions
,
ITextFileService
,
snapshotToString
,
stringToSnapshot
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IWorkingCopy
,
IWorkingCopyBackup
,
IWorkingCopyService
,
WorkingCopyCapabilities
}
from
'
vs/workbench/services/workingCopy/common/workingCopyService
'
;
...
...
@@ -46,6 +50,8 @@ const SEARCH_EDITOR_EXT = '.code-search';
export
class
SearchEditorInput
extends
EditorInput
{
static
readonly
ID
:
string
=
'
workbench.editorinputs.searchEditorInput
'
;
private
memento
:
Memento
;
private
dirty
:
boolean
=
false
;
private
model
:
Promise
<
ITextModel
>
;
private
_cachedModel
:
ITextModel
|
undefined
;
...
...
@@ -57,7 +63,11 @@ export class SearchEditorInput extends EditorInput {
private
_config
:
Readonly
<
SearchConfiguration
>
;
public
get
config
():
Readonly
<
SearchConfiguration
>
{
return
this
.
_config
;
}
public
set
config
(
value
:
Readonly
<
SearchConfiguration
>
)
{
this
.
_config
=
value
;
this
.
_onDidChangeLabel
.
fire
();
}
public
set
config
(
value
:
Readonly
<
SearchConfiguration
>
)
{
this
.
_config
=
value
;
this
.
memento
.
getMemento
(
StorageScope
.
WORKSPACE
).
searchConfig
=
value
;
this
.
_onDidChangeLabel
.
fire
();
}
get
resource
()
{
return
this
.
backingUri
||
this
.
modelUri
;
...
...
@@ -76,7 +86,8 @@ export class SearchEditorInput extends EditorInput {
@
IWorkingCopyService
private
readonly
workingCopyService
:
IWorkingCopyService
,
@
IFilesConfigurationService
private
readonly
filesConfigurationService
:
IFilesConfigurationService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
@
IRemotePathService
private
readonly
remotePathService
:
IRemotePathService
@
IRemotePathService
private
readonly
remotePathService
:
IRemotePathService
,
@
IStorageService
storageService
:
IStorageService
,
)
{
super
();
...
...
@@ -93,6 +104,9 @@ export class SearchEditorInput extends EditorInput {
throw
Error
(
'
SearchEditorInput must be invoked with a SearchEditorScheme uri
'
);
}
this
.
memento
=
new
Memento
(
SearchEditorInput
.
ID
,
storageService
);
storageService
.
onWillSaveState
(()
=>
this
.
memento
.
saveMemento
());
const
input
=
this
;
const
workingCopyAdapter
=
new
class
implements
IWorkingCopy
{
readonly
resource
=
input
.
modelUri
;
...
...
@@ -283,15 +297,20 @@ export const getOrMakeSearchEditorInput = (
{
backingUri
:
URI
,
text
?:
never
,
modelUri
?:
never
}))
):
SearchEditorInput
=>
{
const
defaultConfig
:
SearchConfiguration
=
{
caseSensitive
:
false
,
contextLines
:
0
,
excludes
:
''
,
includes
:
''
,
query
:
''
,
regexp
:
false
,
showIncludesExcludes
:
false
,
useIgnores
:
true
,
wholeWord
:
false
};
let
config
=
{
...
defaultConfig
,
...
existingData
.
config
};
const
modelUri
=
existingData
.
modelUri
??
URI
.
from
({
scheme
:
SearchEditorScheme
,
fragment
:
`
${
Math
.
random
()}
`
});
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
modelService
=
accessor
.
get
(
IModelService
);
const
backupService
=
accessor
.
get
(
IBackupFileService
);
const
modeService
=
accessor
.
get
(
IModeService
);
const
storageService
=
accessor
.
get
(
IStorageService
);
const
configurationService
=
accessor
.
get
(
IConfigurationService
);
const
reuseOldSettings
=
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
).
searchEditor
?.
experimental
?.
reusePriorSearchConfiguration
;
const
priorConfig
:
SearchConfiguration
=
reuseOldSettings
?
new
Memento
(
SearchEditorInput
.
ID
,
storageService
).
getMemento
(
StorageScope
.
WORKSPACE
).
searchConfig
:
{};
const
defaultConfig
=
defaultSearchConfig
();
let
config
=
{
...
defaultConfig
,
...
priorConfig
,
...
existingData
.
config
};
const
modelUri
=
existingData
.
modelUri
??
URI
.
from
({
scheme
:
SearchEditorScheme
,
fragment
:
`
${
Math
.
random
()}
`
});
const
existing
=
inputs
.
get
(
modelUri
.
toString
()
+
existingData
.
backingUri
?.
toString
());
if
(
existing
)
{
...
...
src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.ts
浏览文件 @
70a9b8b2
...
...
@@ -106,15 +106,15 @@ function fileMatchToSearchResultFormat(fileMatch: FileMatch, labelFormatter: (x:
return
{
text
,
matchRanges
};
}
const
contentPatternToSearchConfiguration
=
(
pattern
:
ITextQuery
|
null
,
includes
:
string
,
excludes
:
string
,
contextLines
:
number
):
Partial
<
SearchConfiguration
>
=>
{
const
contentPatternToSearchConfiguration
=
(
pattern
:
ITextQuery
,
includes
:
string
,
excludes
:
string
,
contextLines
:
number
):
SearchConfiguration
=>
{
return
{
query
:
pattern
?
.
contentPattern
.
pattern
,
regexp
:
pattern
?
.
contentPattern
.
isRegExp
,
caseSensitive
:
pattern
?
.
contentPattern
.
isCaseSensitive
,
wholeWord
:
pattern
?
.
contentPattern
.
isWordMatch
,
query
:
pattern
.
contentPattern
.
pattern
,
regexp
:
!!
pattern
.
contentPattern
.
isRegExp
,
caseSensitive
:
!!
pattern
.
contentPattern
.
isCaseSensitive
,
wholeWord
:
!!
pattern
.
contentPattern
.
isWordMatch
,
excludes
,
includes
,
showIncludesExcludes
:
!!
(
includes
||
excludes
||
pattern
?.
userDisabledExcludesAndIgnoreFiles
),
useIgnores
:
pattern
?.
userDisabledExcludesAndIgnoreFiles
===
undefined
?
undefined
:
!
pattern
.
userDisabledExcludesAndIgnoreFiles
,
useIgnores
:
!!
(
pattern
?.
userDisabledExcludesAndIgnoreFiles
===
undefined
?
undefined
:
!
pattern
.
userDisabledExcludesAndIgnoreFiles
)
,
contextLines
,
};
};
...
...
@@ -144,9 +144,7 @@ export const serializeSearchConfiguration = (config: Partial<SearchConfiguration
export
const
extractSearchQueryFromModel
=
(
model
:
ITextModel
):
SearchConfiguration
=>
extractSearchQueryFromLines
(
model
.
getValueInRange
(
new
Range
(
1
,
1
,
6
,
1
)).
split
(
lineDelimiter
));
export
const
extractSearchQueryFromLines
=
(
lines
:
string
[]):
SearchConfiguration
=>
{
const
query
:
SearchConfiguration
=
{
export
const
defaultSearchConfig
=
():
SearchConfiguration
=>
({
query
:
''
,
includes
:
''
,
excludes
:
''
,
...
...
@@ -156,7 +154,11 @@ export const extractSearchQueryFromLines = (lines: string[]): SearchConfiguratio
wholeWord
:
false
,
contextLines
:
0
,
showIncludesExcludes
:
false
,
};
});
export
const
extractSearchQueryFromLines
=
(
lines
:
string
[]):
SearchConfiguration
=>
{
const
query
=
defaultSearchConfig
();
const
unescapeNewlines
=
(
str
:
string
)
=>
{
let
out
=
''
;
...
...
@@ -207,6 +209,7 @@ export const extractSearchQueryFromLines = (lines: string[]): SearchConfiguratio
export
const
serializeSearchResultForEditor
=
(
searchResult
:
SearchResult
,
rawIncludePattern
:
string
,
rawExcludePattern
:
string
,
contextLines
:
number
,
labelFormatter
:
(
x
:
URI
)
=>
string
):
{
matchRanges
:
Range
[],
text
:
string
,
config
:
Partial
<
SearchConfiguration
>
}
=>
{
if
(
!
searchResult
.
query
)
{
throw
Error
(
'
Internal Error: Expected query, got null
'
);
}
const
config
=
contentPatternToSearchConfiguration
(
searchResult
.
query
,
rawIncludePattern
,
rawExcludePattern
,
contextLines
);
const
filecount
=
searchResult
.
fileCount
()
>
1
?
localize
(
'
numFiles
'
,
"
{0} files
"
,
searchResult
.
fileCount
())
:
localize
(
'
oneFile
'
,
"
1 file
"
);
...
...
src/vs/workbench/services/search/common/search.ts
浏览文件 @
70a9b8b2
...
...
@@ -345,7 +345,10 @@ export interface ISearchConfigurationProperties {
collapseResults
:
'
auto
'
|
'
alwaysCollapse
'
|
'
alwaysExpand
'
;
searchOnType
:
boolean
;
searchOnTypeDebouncePeriod
:
number
;
searchEditor
:
{
doubleClickBehaviour
:
'
selectWord
'
|
'
goToLocation
'
|
'
openLocationToSide
'
};
searchEditor
:
{
doubleClickBehaviour
:
'
selectWord
'
|
'
goToLocation
'
|
'
openLocationToSide
'
,
experimental
:
{
reusePriorSearchConfiguration
:
boolean
}
};
sortOrder
:
SearchSortOrder
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录