Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: remember state of compilation #998

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 38 additions & 25 deletions crates/tinymist/src/actor/typ_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,36 @@ impl CompileHandler {
}
false
}

fn notify_compile_inner(&self, snap: &CompiledArtifact<LspCompilerFeat>) {
self.notify_diagnostics(
&snap.world,
snap.doc.clone().err().unwrap_or_default(),
snap.warnings.clone(),
);

self.export.signal(snap, snap.signal);

self.editor_tx
.send(EditorRequest::Status(
self.diag_group.clone(),
if snap.doc.is_ok() {
TinymistCompileStatusEnum::CompileSuccess
} else {
TinymistCompileStatusEnum::CompileError
},
))
.unwrap();

#[cfg(feature = "preview")]
if let Some(inner) = self.inner.read().as_ref() {
let res = snap
.doc
.clone()
.map_err(|_| typst_preview::CompileStatus::CompileError);
inner.notify_compile(res, snap.signal.by_fs_events, snap.signal.by_entry_update);
}
}
}

impl CompilationHandle<LspCompilerFeat> for CompileHandler {
Expand Down Expand Up @@ -232,33 +262,16 @@ impl CompilationHandle<LspCompilerFeat> for CompileHandler {
*n_rev = snap.world.revision().get();
}

self.notify_diagnostics(
&snap.world,
snap.doc.clone().err().unwrap_or_default(),
snap.warnings.clone(),
);

self.export.signal(snap, snap.signal);

self.editor_tx
.send(EditorRequest::Status(
self.diag_group.clone(),
if snap.doc.is_ok() {
TinymistCompileStatusEnum::CompileSuccess
} else {
TinymistCompileStatusEnum::CompileError
},
))
.unwrap();
self.notify_compile_inner(snap);
}

#[cfg(feature = "preview")]
if let Some(inner) = self.inner.read().as_ref() {
let res = snap
.doc
.clone()
.map_err(|_| typst_preview::CompileStatus::CompileError);
inner.notify_compile(res, snap.signal.by_fs_events, snap.signal.by_entry_update);
fn restore_compile(&self, snap: &CompiledArtifact<LspCompilerFeat>, _rep: CompileReport) {
{
let mut n_rev = self.notified_revision.lock();
*n_rev = snap.world.revision().get();
}

self.notify_compile_inner(snap);
}
}

Expand Down
Loading
Loading