Avoid creating a multitoken when finding definitions
This will avoid showing a query-server popup on hovers. When someone does CTRL+hover on source code in a database archive, the definitions provider is triggered. The first time this is run, there will be a query that is invoked in order to find definitions. This can be a long process. Previously, this query brought up a popup window that could be cancelled. However, this is confusing users since the query is automatically cancelled when the mouse hovers away from the element. The downside of this PR is that even when find definitions is explicitly invoked, (using F12), there will still be no hover. I think this is an improvement, but I am happy to discuss if others disagree.
This commit is contained in:
Родитель
9594a5e951
Коммит
ef69a51741
|
@ -1086,23 +1086,27 @@ async function activateWithInstalledDistribution(
|
|||
// Jump-to-definition and find-references
|
||||
void extLogger.log("Registering jump-to-definition handlers.");
|
||||
|
||||
languages.registerDefinitionProvider(
|
||||
{ scheme: zipArchiveScheme },
|
||||
new TemplateQueryDefinitionProvider(
|
||||
cliServer,
|
||||
qs,
|
||||
dbm,
|
||||
contextualQueryStorageDir,
|
||||
ctx.subscriptions.push(
|
||||
languages.registerDefinitionProvider(
|
||||
{ scheme: zipArchiveScheme },
|
||||
new TemplateQueryDefinitionProvider(
|
||||
cliServer,
|
||||
qs,
|
||||
dbm,
|
||||
contextualQueryStorageDir,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
languages.registerReferenceProvider(
|
||||
{ scheme: zipArchiveScheme },
|
||||
new TemplateQueryReferenceProvider(
|
||||
cliServer,
|
||||
qs,
|
||||
dbm,
|
||||
contextualQueryStorageDir,
|
||||
ctx.subscriptions.push(
|
||||
languages.registerReferenceProvider(
|
||||
{ scheme: zipArchiveScheme },
|
||||
new TemplateQueryReferenceProvider(
|
||||
cliServer,
|
||||
qs,
|
||||
dbm,
|
||||
contextualQueryStorageDir,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -88,25 +88,18 @@ export class TemplateQueryDefinitionProvider implements DefinitionProvider {
|
|||
uriString: string,
|
||||
token: CancellationToken,
|
||||
): Promise<LocationLink[]> {
|
||||
return withProgress(
|
||||
async (progress, tokenInner) => {
|
||||
const multiToken = new MultiCancellationToken(token, tokenInner);
|
||||
return getLocationsForUriString(
|
||||
this.cli,
|
||||
this.qs,
|
||||
this.dbm,
|
||||
uriString,
|
||||
KeyType.DefinitionQuery,
|
||||
this.queryStorageDir,
|
||||
progress,
|
||||
multiToken,
|
||||
(src, _dest) => src === uriString,
|
||||
);
|
||||
},
|
||||
{
|
||||
cancellable: true,
|
||||
title: "Finding definitions",
|
||||
},
|
||||
// Do not create a multitoken here. There will be no popup and users cannot click on anything to cancel this operation.
|
||||
// This is because finding definitions can be triggered by a hover, which should not have a popup.
|
||||
return getLocationsForUriString(
|
||||
this.cli,
|
||||
this.qs,
|
||||
this.dbm,
|
||||
uriString,
|
||||
KeyType.DefinitionQuery,
|
||||
this.queryStorageDir,
|
||||
() => {}, // noop
|
||||
token,
|
||||
(src, _dest) => src === uriString,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +154,7 @@ export class TemplateQueryReferenceProvider implements ReferenceProvider {
|
|||
uriString: string,
|
||||
token: CancellationToken,
|
||||
): Promise<FullLocationLink[]> {
|
||||
// Create a multitoken here. There will be a popup and users can click on it to cancel this operation.
|
||||
return withProgress(
|
||||
async (progress, tokenInner) => {
|
||||
const multiToken = new MultiCancellationToken(token, tokenInner);
|
||||
|
|
Загрузка…
Ссылка в новой задаче