Return synchronized if seen document version > required document version for resolve action endpoint

This commit is contained in:
Adam Ratzman 2023-04-10 12:30:24 -07:00
Родитель 3be43f6abb
Коммит 51fbefedeb
3 изменённых файлов: 19 добавлений и 6 удалений

Просмотреть файл

@ -58,13 +58,15 @@ internal class DefaultLSPDocumentSynchronizer : LSPDocumentSynchronizer
requiredHostDocumentVersion,
hostDocumentUri,
rejectOnNewerParallelRequest: true,
cancellationToken);
cancellationToken,
isResolveCodeActionSync: false);
public override async Task<SynchronizedResult<TVirtualDocumentSnapshot>> TrySynchronizeVirtualDocumentAsync<TVirtualDocumentSnapshot>(
int requiredHostDocumentVersion,
Uri hostDocumentUri,
bool rejectOnNewerParallelRequest,
CancellationToken cancellationToken)
CancellationToken cancellationToken,
bool isResolveCodeActionSync = false)
where TVirtualDocumentSnapshot : class
{
if (hostDocumentUri is null)
@ -90,7 +92,7 @@ internal class DefaultLSPDocumentSynchronizer : LSPDocumentSynchronizer
}
// Currently tracked synchronizing context is not sufficient, need to update a new one.
onSynchronizedTask = documentContext.GetSynchronizationTaskAsync(requiredHostDocumentVersion, rejectOnNewerParallelRequest, cancellationToken);
onSynchronizedTask = documentContext.GetSynchronizationTaskAsync(requiredHostDocumentVersion, rejectOnNewerParallelRequest, cancellationToken, isResolveCodeActionSync);
}
var onSynchronizedResult = await onSynchronizedTask.ConfigureAwait(false);
@ -279,7 +281,7 @@ internal class DefaultLSPDocumentSynchronizer : LSPDocumentSynchronizer
}
}
public Task<bool> GetSynchronizationTaskAsync(int requiredHostDocumentVersion, bool rejectOnNewerParallelRequest, CancellationToken cancellationToken)
public Task<bool> GetSynchronizationTaskAsync(int requiredHostDocumentVersion, bool rejectOnNewerParallelRequest, CancellationToken cancellationToken, bool isResolveCodeActionSync = false)
{
// Cancel any out-of-date existing synchronizing contexts.
@ -295,6 +297,14 @@ internal class DefaultLSPDocumentSynchronizer : LSPDocumentSynchronizer
}
}
// TODO this is a partial workaround to fix prefix completion by avoiding sync (which times out during resolve endpoint) if we are currently at a higher version value
// this does not fix postfix completion and should be superceded by eventual synchronization fix
if (isResolveCodeActionSync && SeenHostDocumentVersion >= requiredHostDocumentVersion)
{
return Task.FromResult(true);
}
var synchronizingContext = new DocumentSynchronizingContext(requiredHostDocumentVersion, rejectOnNewerParallelRequest, _synchronizingTimeout, cancellationToken);
_synchronizingContexts.Add(synchronizingContext);
return synchronizingContext.OnSynchronizedAsync;

Просмотреть файл

@ -20,7 +20,8 @@ internal abstract class LSPDocumentSynchronizer : LSPDocumentChangeListener
int requiredHostDocumentVersion,
Uri hostDocumentUri,
bool rejectOnNewerParallelRequest,
CancellationToken cancellationToken)
CancellationToken cancellationToken,
bool isResolveCodeActionEndpoint = false)
where TVirtualDocumentSnapshot : VirtualDocumentSnapshot;
[Obsolete]

Просмотреть файл

@ -1015,7 +1015,9 @@ internal class DefaultRazorLanguageServerCustomMessageTarget : RazorLanguageServ
(synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<CSharpVirtualDocumentSnapshot>(
request.HostDocument.Version,
request.HostDocument.Uri,
cancellationToken);
rejectOnNewerParallelRequest: true,
cancellationToken,
isResolveCodeActionEndpoint: true);
languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
}
else