add conditional noop render back

It makes it much slower without stubbing this out
pull/2267/head
Skyler Hawthorne 2 years ago
parent 69c9e44ef2
commit b8a07f7d15

@ -7,7 +7,6 @@ use std::collections::HashMap;
use smallvec::SmallVec; use smallvec::SmallVec;
// Heavily based on https://github.com/codemirror/closebrackets/ // Heavily based on https://github.com/codemirror/closebrackets/
pub const DEFAULT_PAIRS: &[(char, char)] = &[ pub const DEFAULT_PAIRS: &[(char, char)] = &[
('(', ')'), ('(', ')'),
('{', '}'), ('{', '}'),

@ -253,6 +253,10 @@ impl Application {
Ok(app) Ok(app)
} }
#[cfg(feature = "integration")]
fn render(&mut self) {}
#[cfg(not(feature = "integration"))]
fn render(&mut self) { fn render(&mut self) {
let compositor = &mut self.compositor; let compositor = &mut self.compositor;

@ -2504,13 +2504,6 @@ fn insert_at_line_end(cx: &mut Context) {
doc.set_selection(view.id, selection); doc.set_selection(view.id, selection);
} }
/// Sometimes when applying formatting changes we want to mark the buffer as unmodified, for
/// example because we just applied the same changes while saving.
enum Modified {
SetUnmodified,
LeaveModified,
}
// Creates an LspCallback that waits for formatting changes to be computed. When they're done, // Creates an LspCallback that waits for formatting changes to be computed. When they're done,
// it applies them, but only if the doc hasn't changed. // it applies them, but only if the doc hasn't changed.
// //
@ -2519,7 +2512,6 @@ enum Modified {
async fn make_format_callback( async fn make_format_callback(
doc_id: DocumentId, doc_id: DocumentId,
doc_version: i32, doc_version: i32,
modified: Modified,
format: impl Future<Output = Result<Transaction, FormatterError>> + Send + 'static, format: impl Future<Output = Result<Transaction, FormatterError>> + Send + 'static,
) -> anyhow::Result<job::Callback> { ) -> anyhow::Result<job::Callback> {
let format = format.await?; let format = format.await?;
@ -2536,17 +2528,15 @@ async fn make_format_callback(
doc.append_changes_to_history(view.id); doc.append_changes_to_history(view.id);
doc.detect_indent_and_line_ending(); doc.detect_indent_and_line_ending();
view.ensure_cursor_in_view(doc, scrolloff); view.ensure_cursor_in_view(doc, scrolloff);
if let Modified::SetUnmodified = modified {
doc.reset_modified();
}
} else { } else {
log::info!("discarded formatting changes because the document changed"); log::info!("discarded formatting changes because the document changed");
} }
}); });
Ok(call) Ok(call)
} }
#[derive(PartialEq)] #[derive(PartialEq, Eq)]
pub enum Open { pub enum Open {
Below, Below,
Above, Above,

@ -273,12 +273,7 @@ fn write_impl(
let fmt = if auto_format { let fmt = if auto_format {
doc.auto_format().map(|fmt| { doc.auto_format().map(|fmt| {
let shared = fmt.shared(); let shared = fmt.shared();
let callback = make_format_callback( let callback = make_format_callback(doc.id(), doc.version(), shared.clone());
doc.id(),
doc.version(),
Modified::SetUnmodified,
shared.clone(),
);
jobs.callback(callback); jobs.callback(callback);
shared shared
}) })
@ -346,8 +341,7 @@ fn format(
let doc = doc!(cx.editor); let doc = doc!(cx.editor);
if let Some(format) = doc.format() { if let Some(format) = doc.format() {
let callback = let callback = make_format_callback(doc.id(), doc.version(), format);
make_format_callback(doc.id(), doc.version(), Modified::LeaveModified, format);
cx.jobs.callback(callback); cx.jobs.callback(callback);
} }
@ -593,12 +587,7 @@ fn write_all_impl(
let fmt = if auto_format { let fmt = if auto_format {
doc.auto_format().map(|fmt| { doc.auto_format().map(|fmt| {
let shared = fmt.shared(); let shared = fmt.shared();
let callback = make_format_callback( let callback = make_format_callback(doc.id(), doc.version(), shared.clone());
doc.id(),
doc.version(),
Modified::SetUnmodified,
shared.clone(),
);
jobs.callback(callback); jobs.callback(callback);
shared shared
}) })

Loading…
Cancel
Save