Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
44dc55b9
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,发现更多精彩内容 >>
提交
44dc55b9
编写于
9月 05, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #57951 - remove $cancelSearch
上级
39933962
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
70 deletion
+38
-70
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
+7
-42
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+3
-4
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+5
-1
src/vs/workbench/api/node/extHostWorkspace.ts
src/vs/workbench/api/node/extHostWorkspace.ts
+8
-19
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+15
-4
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
浏览文件 @
44dc55b9
...
...
@@ -24,7 +24,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IWorkspaceEditingService
}
from
'
vs/workbench/services/workspace/common/workspaceEditing
'
;
import
{
ExtHostContext
,
ExtHostWorkspaceShape
,
IExtHostContext
,
MainContext
,
MainThreadWorkspaceShape
}
from
'
../node/extHost.protocol
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
CancellationTokenSource
,
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
@
extHostNamedCustomer
(
MainContext
.
MainThreadWorkspace
)
export
class
MainThreadWorkspace
implements
MainThreadWorkspaceShape
{
...
...
@@ -113,7 +113,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
// --- search ---
$startFileSearch
(
includePattern
:
string
,
includeFolder
:
string
,
excludePatternOrDisregardExcludes
:
string
|
false
,
maxResults
:
number
,
requestId
:
number
):
Thenable
<
URI
[]
>
{
$startFileSearch
(
includePattern
:
string
,
includeFolder
:
string
,
excludePatternOrDisregardExcludes
:
string
|
false
,
maxResults
:
number
,
token
:
CancellationToken
):
Thenable
<
URI
[]
>
{
const
workspace
=
this
.
_contextService
.
getWorkspace
();
if
(
!
workspace
.
folders
.
length
)
{
return
undefined
;
...
...
@@ -158,8 +158,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
this
.
_searchService
.
extendQuery
(
query
);
const
tokenSource
=
new
CancellationTokenSource
();
const
search
=
this
.
_searchService
.
search
(
query
,
tokenSource
.
token
).
then
(
result
=>
{
return
this
.
_searchService
.
search
(
query
,
token
).
then
(
result
=>
{
return
result
.
results
.
map
(
m
=>
m
.
resource
);
},
err
=>
{
if
(
!
isPromiseCanceledError
(
err
))
{
...
...
@@ -167,18 +166,9 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
}
return
undefined
;
});
this
.
_activeCancelTokens
[
requestId
]
=
tokenSource
;
const
onDone
=
()
=>
{
tokenSource
.
dispose
();
delete
this
.
_activeCancelTokens
[
requestId
];
};
search
.
then
(
onDone
,
onDone
);
return
search
;
}
$startTextSearch
(
pattern
:
IPatternInfo
,
options
:
IQueryOptions
,
requestId
:
number
):
Thenable
<
void
>
{
$startTextSearch
(
pattern
:
IPatternInfo
,
options
:
IQueryOptions
,
requestId
:
number
,
token
:
CancellationToken
):
Thenable
<
void
>
{
const
workspace
=
this
.
_contextService
.
getWorkspace
();
const
folders
=
workspace
.
folders
.
map
(
folder
=>
folder
.
uri
);
...
...
@@ -191,8 +181,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
}
};
const
tokenSource
=
new
CancellationTokenSource
();
const
search
=
this
.
_searchService
.
search
(
query
,
tokenSource
.
token
,
onProgress
).
then
(
const
search
=
this
.
_searchService
.
search
(
query
,
token
,
onProgress
).
then
(
()
=>
{
return
null
;
},
...
...
@@ -204,17 +193,10 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
return
undefined
;
});
this
.
_activeCancelTokens
[
requestId
]
=
tokenSource
;
const
onDone
=
()
=>
{
tokenSource
.
dispose
();
delete
this
.
_activeCancelTokens
[
requestId
];
};
search
.
then
(
onDone
,
onDone
);
return
search
;
}
$checkExists
(
includes
:
string
[],
requestId
:
number
):
Thenable
<
boolean
>
{
$checkExists
(
includes
:
string
[],
token
:
CancellationToken
):
Thenable
<
boolean
>
{
const
queryBuilder
=
this
.
_instantiationService
.
createInstance
(
QueryBuilder
);
const
folders
=
this
.
_contextService
.
getWorkspace
().
folders
.
map
(
folder
=>
folder
.
uri
);
const
query
=
queryBuilder
.
file
(
folders
,
{
...
...
@@ -222,34 +204,17 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
exists
:
true
});
const
tokenSource
=
new
CancellationTokenSource
();
const
search
=
this
.
_searchService
.
search
(
query
,
tokenSource
.
token
).
then
(
return
this
.
_searchService
.
search
(
query
,
token
).
then
(
result
=>
{
delete
this
.
_activeCancelTokens
[
requestId
];
return
result
.
limitHit
;
},
err
=>
{
delete
this
.
_activeCancelTokens
[
requestId
];
if
(
!
isPromiseCanceledError
(
err
))
{
return
TPromise
.
wrapError
(
err
);
}
return
undefined
;
});
this
.
_activeCancelTokens
[
requestId
]
=
tokenSource
;
return
search
;
}
$cancelSearch
(
requestId
:
number
):
Thenable
<
boolean
>
{
const
tokenSource
=
this
.
_activeCancelTokens
[
requestId
];
if
(
tokenSource
)
{
delete
this
.
_activeCancelTokens
[
requestId
];
tokenSource
.
cancel
();
return
TPromise
.
as
(
true
);
}
return
undefined
;
}
// --- save & edit resources ---
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
44dc55b9
...
...
@@ -470,10 +470,9 @@ export interface ExtHostUrlsShape {
}
export
interface
MainThreadWorkspaceShape
extends
IDisposable
{
$startFileSearch
(
includePattern
:
string
,
includeFolder
:
string
,
excludePatternOrDisregardExcludes
:
string
|
false
,
maxResults
:
number
,
requestId
:
number
):
Thenable
<
UriComponents
[]
>
;
$startTextSearch
(
query
:
IPatternInfo
,
options
:
IQueryOptions
,
requestId
:
number
):
Thenable
<
void
>
;
$checkExists
(
includes
:
string
[],
requestId
:
number
):
Thenable
<
boolean
>
;
$cancelSearch
(
requestId
:
number
):
Thenable
<
boolean
>
;
$startFileSearch
(
includePattern
:
string
,
includeFolder
:
string
,
excludePatternOrDisregardExcludes
:
string
|
false
,
maxResults
:
number
,
token
:
CancellationToken
):
Thenable
<
UriComponents
[]
>
;
$startTextSearch
(
query
:
IPatternInfo
,
options
:
IQueryOptions
,
requestId
:
number
,
token
:
CancellationToken
):
Thenable
<
void
>
;
$checkExists
(
includes
:
string
[],
token
:
CancellationToken
):
Thenable
<
boolean
>
;
$saveAll
(
includeUntitled
?:
boolean
):
Thenable
<
boolean
>
;
$updateWorkspaceFolders
(
extensionName
:
string
,
index
:
number
,
deleteCount
:
number
,
workspaceFoldersToAdd
:
{
uri
:
UriComponents
,
name
?:
string
}[]):
Thenable
<
void
>
;
}
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
44dc55b9
...
...
@@ -93,7 +93,7 @@ export class ExtHostSearch implements ExtHostSearchShape {
});
}
else
{
const
indexProvider
=
this
.
_fileIndexProvider
.
get
(
handle
);
return
this
.
_fileIndexSearchManager
.
fileSearch
(
query
,
indexProvider
,
batch
=>
{
const
searchP
=
this
.
_fileIndexSearchManager
.
fileSearch
(
query
,
indexProvider
,
batch
=>
{
this
.
_proxy
.
$handleFileMatch
(
handle
,
session
,
batch
.
map
(
p
=>
p
.
resource
));
}).
then
(
null
,
err
=>
{
if
(
!
isPromiseCanceledError
(
err
))
{
...
...
@@ -102,6 +102,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
return
null
;
});
token
.
onCancellationRequested
(()
=>
searchP
.
cancel
());
return
searchP
;
}
}
...
...
src/vs/workbench/api/node/extHostWorkspace.ts
浏览文件 @
44dc55b9
...
...
@@ -24,6 +24,7 @@ import { Range } from 'vs/workbench/api/node/extHostTypes';
import
{
IExtensionDescription
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
ExtHostWorkspaceShape
,
IMainContext
,
IWorkspaceData
,
MainContext
,
MainThreadMessageServiceShape
,
MainThreadWorkspaceShape
}
from
'
./extHost.protocol
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
function
isFolderEqual
(
folderA
:
URI
,
folderB
:
URI
):
boolean
{
return
isEqual
(
folderA
,
folderB
,
!
isLinux
);
...
...
@@ -345,11 +346,9 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
// --- search ---
findFiles
(
include
:
vscode
.
GlobPattern
,
exclude
:
vscode
.
GlobPattern
,
maxResults
:
number
,
extensionId
:
string
,
token
?:
vscode
.
CancellationToken
):
Thenable
<
vscode
.
Uri
[]
>
{
findFiles
(
include
:
vscode
.
GlobPattern
,
exclude
:
vscode
.
GlobPattern
,
maxResults
:
number
,
extensionId
:
string
,
token
:
vscode
.
CancellationToken
=
CancellationToken
.
None
):
Thenable
<
vscode
.
Uri
[]
>
{
this
.
_logService
.
trace
(
`extHostWorkspace#findFiles: fileSearch, extension:
${
extensionId
}
, entryPoint: findFiles`
);
const
requestId
=
this
.
_requestIdProvider
.
getNext
();
let
includePattern
:
string
;
let
includeFolder
:
string
;
if
(
include
)
{
...
...
@@ -376,14 +375,11 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
return
TPromise
.
wrap
([]);
}
const
result
=
this
.
_proxy
.
$startFileSearch
(
includePattern
,
includeFolder
,
excludePatternOrDisregardExcludes
,
maxResults
,
requestId
);
if
(
token
)
{
token
.
onCancellationRequested
(()
=>
this
.
_proxy
.
$cancelSearch
(
requestId
));
}
return
result
.
then
(
data
=>
Array
.
isArray
(
data
)
?
data
.
map
(
URI
.
revive
)
:
[]);
return
this
.
_proxy
.
$startFileSearch
(
includePattern
,
includeFolder
,
excludePatternOrDisregardExcludes
,
maxResults
,
token
)
.
then
(
data
=>
Array
.
isArray
(
data
)
?
data
.
map
(
URI
.
revive
)
:
[]);
}
findTextInFiles
(
query
:
vscode
.
TextSearchQuery
,
options
:
vscode
.
FindTextInFilesOptions
,
callback
:
(
result
:
vscode
.
TextSearchResult
)
=>
void
,
extensionId
:
string
,
token
?:
vscode
.
CancellationToken
)
{
findTextInFiles
(
query
:
vscode
.
TextSearchQuery
,
options
:
vscode
.
FindTextInFilesOptions
,
callback
:
(
result
:
vscode
.
TextSearchResult
)
=>
void
,
extensionId
:
string
,
token
:
vscode
.
CancellationToken
=
CancellationToken
.
None
)
{
this
.
_logService
.
trace
(
`extHostWorkspace#findTextInFiles: textSearch, extension:
${
extensionId
}
, entryPoint: findTextInFiles`
);
if
(
options
.
previewOptions
&&
options
.
previewOptions
.
totalChars
<=
options
.
previewOptions
.
leadingChars
)
{
...
...
@@ -431,18 +427,11 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
});
};
if
(
token
)
{
if
(
token
.
isCancellationRequested
)
{
return
TPromise
.
wrap
(
undefined
);
}
else
{
token
.
onCancellationRequested
(()
=>
{
isCanceled
=
true
;
this
.
_proxy
.
$cancelSearch
(
requestId
);
});
}
if
(
token
.
isCancellationRequested
)
{
return
TPromise
.
wrap
(
undefined
);
}
return
this
.
_proxy
.
$startTextSearch
(
query
,
queryOptions
,
requestId
).
then
(
return
this
.
_proxy
.
$startTextSearch
(
query
,
queryOptions
,
requestId
,
token
).
then
(
()
=>
{
delete
this
.
_activeSearchCallbacks
[
requestId
];
},
...
...
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
44dc55b9
...
...
@@ -23,6 +23,7 @@ import { URI } from 'vs/base/common/uri';
import
{
ExtHostLogService
}
from
'
vs/workbench/api/node/extHostLogService
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
Counter
}
from
'
vs/base/common/numbers
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
const
nativeExit
=
process
.
exit
.
bind
(
process
);
function
patchProcess
(
allowExit
:
boolean
)
{
...
...
@@ -264,17 +265,27 @@ export class ExtensionHostMain {
return
TPromise
.
as
(
void
0
);
}
const
requestId
=
this
.
_searchRequestIdProvider
.
getNext
();
const
searchP
=
this
.
_mainThreadWorkspace
.
$checkExists
(
globPatterns
,
requestId
);
const
tokenSource
=
new
CancellationTokenSource
();
const
searchP
=
this
.
_mainThreadWorkspace
.
$checkExists
(
globPatterns
,
tokenSource
.
token
);
const
timer
=
setTimeout
(
async
()
=>
{
await
this
.
_mainThreadWorkspace
.
$cancelSearch
(
requestId
);
tokenSource
.
cancel
(
);
this
.
_extensionService
.
activateById
(
extensionId
,
new
ExtensionActivatedByEvent
(
true
,
`workspaceContainsTimeout:
${
globPatterns
.
join
(
'
,
'
)}
`
))
.
then
(
null
,
err
=>
console
.
error
(
err
));
},
ExtensionHostMain
.
WORKSPACE_CONTAINS_TIMEOUT
);
const
exists
=
await
searchP
;
let
exists
:
boolean
;
try
{
exists
=
await
searchP
;
}
catch
(
err
)
{
if
(
!
errors
.
isPromiseCanceledError
(
err
))
{
console
.
error
(
err
);
}
}
tokenSource
.
dispose
();
clearTimeout
(
timer
);
if
(
exists
)
{
// a file was found matching one of the glob patterns
return
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录