Skip to content

Commit

Permalink
Add timeout passes
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraTenshi committed Dec 14, 2023
1 parent f8f648c commit 8a5305c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct EditorView {
/// Tracks if the terminal window is focused by reaction to terminal focus events
terminal_focused: bool,
pub(crate) explorer: Option<Explorer>,
pub timeout_passes: u8,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -83,6 +84,7 @@ impl EditorView {
sticky_nodes: None,
terminal_focused: true,
explorer: None,
timeout_passes: 0u8,
}
}

Expand Down Expand Up @@ -1213,6 +1215,13 @@ impl EditorView {
pub fn handle_idle_timeout(&mut self, cx: &mut commands::Context) -> EventResult {
commands::compute_inlay_hints_for_all_views(cx.editor, cx.jobs);

if cx.editor.config().timeout_passes.is_some() && self.timeout_passes == 0 {
let doc = doc_mut!(cx.editor);
doc.append_changes_to_history(view_mut!(cx.editor));
} else if cx.editor.config().timeout_passes.is_some() && self.timeout_passes > 0 {
self.timeout_passes = self.timeout_passes.saturating_sub(1);
}

if let Some(completion) = &mut self.completion {
return if completion.ensure_item_resolved(cx) {
EventResult::Consumed(None)
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ pub struct Config {
pub popup_border: PopupBorderConfig,
/// Whether to render rainbow highlights. Defaults to `false`.
pub rainbow_brackets: bool,
/// How often a timeout pass has been reached until a new checkpoint is made
pub timeout_passes: Option<u8>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -958,6 +960,7 @@ impl Default for Config {
smart_tab: Some(SmartTabConfig::default()),
popup_border: PopupBorderConfig::None,
rainbow_brackets: false,
timeout_passes: None,
}
}
}
Expand Down

0 comments on commit 8a5305c

Please sign in to comment.