on master help sign in
add conditional noop render back
b8a07f7Skyler Hawthorne
helix-core/src/auto_pairs.rs−1
@@ -7,7 +7,6 @@ use std::collections::HashMap;
7use smallvec::SmallVec;
7use smallvec::SmallVec;
8
8
9// Heavily based on https://github.com/codemirror/closebrackets/
9// Heavily based on https://github.com/codemirror/closebrackets/
10−
11pub const DEFAULT_PAIRS: &[(char, char)] = &[
10pub const DEFAULT_PAIRS: &[(char, char)] = &[
12 ('(', ')'),
11 ('(', ')'),
13 ('{', '}'),
12 ('{', '}'),
helix-term/src/application.rs+4
@@ -253,6 +253,10 @@ impl Application {
253 Ok(app)
253 Ok(app)
254 }
254 }
255
255
256+ #[cfg(feature = "integration")]
257+ fn render(&mut self) {}
258+
259+ #[cfg(not(feature = "integration"))]
256 fn render(&mut self) {
260 fn render(&mut self) {
257 let compositor = &mut self.compositor;
261 let compositor = &mut self.compositor;
258
262
helix-term/src/commands.rs+2−12
@@ -2504,13 +2504,6 @@ fn insert_at_line_end(cx: &mut Context) {
2504 doc.set_selection(view.id, selection);
2504 doc.set_selection(view.id, selection);
2505}
2505}
2506
2506
2507−/// Sometimes when applying formatting changes we want to mark the buffer as unmodified, for
2508−/// example because we just applied the same changes while saving.
2509−enum Modified {
2510− SetUnmodified,
2511− LeaveModified,
2512−}
2513−
2514// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
2507// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
2515// it applies them, but only if the doc hasn't changed.
2508// it applies them, but only if the doc hasn't changed.
2516//
2509//
@@ -2519,7 +2512,6 @@ enum Modified {
2519async fn make_format_callback(
2512async fn make_format_callback(
2520 doc_id: DocumentId,
2513 doc_id: DocumentId,
2521 doc_version: i32,
2514 doc_version: i32,
2522− modified: Modified,
2523 format: impl Future<Output = Result<Transaction, FormatterError>> + Send + 'static,
2515 format: impl Future<Output = Result<Transaction, FormatterError>> + Send + 'static,
2524) -> anyhow::Result<job::Callback> {
2516) -> anyhow::Result<job::Callback> {
2525 let format = format.await?;
2517 let format = format.await?;
@@ -2536,17 +2528,15 @@ async fn make_format_callback(
2536 doc.append_changes_to_history(view.id);
2528 doc.append_changes_to_history(view.id);
2537 doc.detect_indent_and_line_ending();
2529 doc.detect_indent_and_line_ending();
2538 view.ensure_cursor_in_view(doc, scrolloff);
2530 view.ensure_cursor_in_view(doc, scrolloff);
2539− if let Modified::SetUnmodified = modified {
2540− doc.reset_modified();
2541− }
2542 } else {
2531 } else {
2543 log::info!("discarded formatting changes because the document changed");
2532 log::info!("discarded formatting changes because the document changed");
2544 }
2533 }
2545 });
2534 });
2535+
2546 Ok(call)
2536 Ok(call)
2547}
2537}
2548
2538
2549−#[derive(PartialEq)]
2539+#[derive(PartialEq, Eq)]
2550pub enum Open {
2540pub enum Open {
2551 Below,
2541 Below,
2552 Above,
2542 Above,
helix-term/src/commands/typed.rs+3−14
@@ -273,12 +273,7 @@ fn write_impl(
273 let fmt = if auto_format {
273 let fmt = if auto_format {
274 doc.auto_format().map(|fmt| {
274 doc.auto_format().map(|fmt| {
275 let shared = fmt.shared();
275 let shared = fmt.shared();
276− let callback = make_format_callback(
276+ let callback = make_format_callback(doc.id(), doc.version(), shared.clone());
277− doc.id(),
278− doc.version(),
279− Modified::SetUnmodified,
280− shared.clone(),
281− );
282 jobs.callback(callback);
277 jobs.callback(callback);
283 shared
278 shared
284 })
279 })
@@ -346,8 +341,7 @@ fn format(
346
341
347 let doc = doc!(cx.editor);
342 let doc = doc!(cx.editor);
348 if let Some(format) = doc.format() {
343 if let Some(format) = doc.format() {
349− let callback =
350− make_format_callback(doc.id(), doc.version(), Modified::LeaveModified, format);
344+ let callback = make_format_callback(doc.id(), doc.version(), format);
351 cx.jobs.callback(callback);
345 cx.jobs.callback(callback);
352 }
346 }
353
347
@@ -593,12 +587,7 @@ fn write_all_impl(
593 let fmt = if auto_format {
587 let fmt = if auto_format {
594 doc.auto_format().map(|fmt| {
588 doc.auto_format().map(|fmt| {
595 let shared = fmt.shared();
589 let shared = fmt.shared();
596− let callback = make_format_callback(
590+ let callback = make_format_callback(doc.id(), doc.version(), shared.clone());
597− doc.id(),
598− doc.version(),
599− Modified::SetUnmodified,
600− shared.clone(),
601− );
602 jobs.callback(callback);
591 jobs.callback(callback);
603 shared
592 shared
604 })
593 })