This commit is contained in:
Allison Chou 2023-04-17 17:38:06 -07:00
Родитель 3f8828c06f 6424a7b88d
Коммит d864388543
3 изменённых файлов: 46 добавлений и 5 удалений

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

@ -38,4 +38,4 @@
"insertionTitlePrefix": "[17.7P1]"
}
}
}
}

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

@ -100,6 +100,30 @@ internal class DefaultLSPDocumentSynchronizer : LSPDocumentSynchronizer
return new SynchronizedResult<TVirtualDocumentSnapshot>(onSynchronizedResult, virtualDocumentSnapshot);
}
internal SynchronizedResult<TVirtualDocumentSnapshot>? TryReturnPossiblyFutureSnapshot<TVirtualDocumentSnapshot>(
int requiredHostDocumentVersion,
Uri hostDocumentUri) where TVirtualDocumentSnapshot : VirtualDocumentSnapshot
{
lock (_documentContextLock)
{
var preSyncedSnapshot = GetVirtualDocumentSnapshot<TVirtualDocumentSnapshot>(hostDocumentUri);
var virtualDocumentUri = preSyncedSnapshot.Uri;
if (!_virtualDocumentContexts.TryGetValue(virtualDocumentUri, out var documentContext))
{
// Document was deleted/removed in mid-synchronization
return new SynchronizedResult<TVirtualDocumentSnapshot>(false, preSyncedSnapshot);
}
if (requiredHostDocumentVersion <= documentContext.SeenHostDocumentVersion)
{
// Already synchronized
return new SynchronizedResult<TVirtualDocumentSnapshot>(true, preSyncedSnapshot);
}
}
return null;
}
[Obsolete]
public override Task<bool> TrySynchronizeVirtualDocumentAsync(int requiredHostDocumentVersion, VirtualDocumentSnapshot virtualDocument, CancellationToken cancellationToken)
=> TrySynchronizeVirtualDocumentAsync(requiredHostDocumentVersion, virtualDocument, rejectOnNewerParallelRequest: true, cancellationToken);

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

@ -1012,10 +1012,27 @@ internal class DefaultRazorLanguageServerCustomMessageTarget : RazorLanguageServ
}
else if (request.OriginatingKind == RazorLanguageKind.CSharp)
{
(synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync<CSharpVirtualDocumentSnapshot>(
request.HostDocument.Version,
request.HostDocument.Uri,
cancellationToken);
// 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
var futureDataSyncResult =
(_documentSynchronizer as DefaultLSPDocumentSynchronizer)?.TryReturnPossiblyFutureSnapshot<CSharpVirtualDocumentSnapshot>(
request.HostDocument.Version,
request.HostDocument.Uri);
if (futureDataSyncResult?.Synchronized == true)
{
(synchronized, virtualDocumentSnapshot) = futureDataSyncResult;
}
else
{
(synchronized, virtualDocumentSnapshot) = await _documentSynchronizer
.TrySynchronizeVirtualDocumentAsync<CSharpVirtualDocumentSnapshot>(
request.HostDocument.Version,
request.HostDocument.Uri,
rejectOnNewerParallelRequest: true,
cancellationToken);
}
languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
}
else