mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:01:30 +00:00
Gracefully handle a race condition in code completion (issue 40008)
Change-Id: I4dcef63210e2318594fe15484e00b72ca126e49a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130760 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
ac4b43f0a8
commit
5b6bdaba64
1 changed files with 10 additions and 2 deletions
|
@ -89,9 +89,17 @@ class CompletionRanking {
|
|||
return await receivePort.first;
|
||||
}
|
||||
|
||||
/// Makes a next-token prediction starting at the completion request cursor
|
||||
/// and walking back to find previous input tokens.
|
||||
/// Return a next-token prediction starting at the completion request cursor
|
||||
/// and walking back to find previous input tokens, or `null` if the
|
||||
/// prediction isolates are not running.
|
||||
Future<Map<String, double>> predict(DartCompletionRequest request) async {
|
||||
if (_writes == null || _writes.isEmpty) {
|
||||
// The field `_writes` is initialized in `start`, but the code that
|
||||
// invokes `start` doesn't wait for it complete. That means that it's
|
||||
// possible for this method to be invoked before `_writes` is initialized.
|
||||
// In those cases we return `null`
|
||||
return null;
|
||||
}
|
||||
final query = constructQuery(request, _LOOKBACK);
|
||||
if (query == null) {
|
||||
return Future.value();
|
||||
|
|
Loading…
Reference in a new issue