mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 03:59:55 +00:00
Create anchors with latest snapshot when completions are ready
Using the previous snapshot was panicking.
This commit is contained in:
parent
fde03b1b37
commit
ae0237c21b
1 changed files with 3 additions and 3 deletions
|
@ -856,13 +856,13 @@ impl MultiBuffer {
|
||||||
where
|
where
|
||||||
T: ToOffset,
|
T: ToOffset,
|
||||||
{
|
{
|
||||||
let snapshot = self.snapshot(cx);
|
let anchor = self.read(cx).anchor_before(position);
|
||||||
let anchor = snapshot.anchor_before(position);
|
|
||||||
let buffer = self.buffers.borrow()[&anchor.buffer_id].buffer.clone();
|
let buffer = self.buffers.borrow()[&anchor.buffer_id].buffer.clone();
|
||||||
let completions =
|
let completions =
|
||||||
buffer.update(cx, |buffer, cx| buffer.completions(anchor.text_anchor, cx));
|
buffer.update(cx, |buffer, cx| buffer.completions(anchor.text_anchor, cx));
|
||||||
cx.foreground().spawn(async move {
|
cx.spawn(|this, cx| async move {
|
||||||
completions.await.map(|completions| {
|
completions.await.map(|completions| {
|
||||||
|
let snapshot = this.read_with(&cx, |buffer, cx| buffer.snapshot(cx));
|
||||||
completions
|
completions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|completion| Completion {
|
.map(|completion| Completion {
|
||||||
|
|
Loading…
Reference in a new issue