|
|
@ -287,9 +287,6 @@ impl Application {
|
|
|
|
where
|
|
|
|
where
|
|
|
|
S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
|
|
|
|
S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
|
|
|
|
let mut idle_handled = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
|
if self.editor.should_close() {
|
|
|
|
if self.editor.should_close() {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -315,52 +312,13 @@ impl Application {
|
|
|
|
self.render();
|
|
|
|
self.render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event = self.editor.wait_event() => {
|
|
|
|
event = self.editor.wait_event() => {
|
|
|
|
log::debug!("received editor event: {:?}", event);
|
|
|
|
let _idle_handled = self.handle_editor_event(event).await;
|
|
|
|
|
|
|
|
|
|
|
|
match event {
|
|
|
|
|
|
|
|
EditorEvent::DocumentSave(event) => {
|
|
|
|
|
|
|
|
self.handle_document_write(event);
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::ConfigEvent(event) => {
|
|
|
|
|
|
|
|
self.handle_config_events(event);
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::LanguageServerMessage((id, call)) => {
|
|
|
|
|
|
|
|
self.handle_language_server_message(call, id).await;
|
|
|
|
|
|
|
|
// limit render calls for fast language server messages
|
|
|
|
|
|
|
|
let last = self.editor.language_servers.incoming.is_empty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if last || self.last_render.elapsed() > LSP_DEADLINE {
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
self.last_render = Instant::now();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::DebuggerEvent(payload) => {
|
|
|
|
|
|
|
|
let needs_render = self.editor.handle_debugger_message(payload).await;
|
|
|
|
|
|
|
|
if needs_render {
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::IdleTimer => {
|
|
|
|
|
|
|
|
self.editor.clear_idle_timer();
|
|
|
|
|
|
|
|
self.handle_idle_timeout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log::debug!("idle handled");
|
|
|
|
|
|
|
|
idle_handled = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for integration tests only, reset the idle timer after every
|
|
|
|
// for integration tests only, reset the idle timer after every
|
|
|
|
// event to signal when test events are done processing
|
|
|
|
// event to signal when test events are done processing
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if idle_handled {
|
|
|
|
if _idle_handled {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -368,6 +326,8 @@ impl Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn handle_config_events(&mut self, config_event: ConfigEvent) {
|
|
|
|
pub fn handle_config_events(&mut self, config_event: ConfigEvent) {
|
|
|
|
match config_event {
|
|
|
|
match config_event {
|
|
|
@ -517,6 +477,49 @@ impl Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
|
|
|
pub async fn handle_editor_event(&mut self, event: EditorEvent) -> bool {
|
|
|
|
|
|
|
|
log::debug!("received editor event: {:?}", event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
match event {
|
|
|
|
|
|
|
|
EditorEvent::DocumentSave(event) => {
|
|
|
|
|
|
|
|
self.handle_document_write(event);
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::ConfigEvent(event) => {
|
|
|
|
|
|
|
|
self.handle_config_events(event);
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::LanguageServerMessage((id, call)) => {
|
|
|
|
|
|
|
|
self.handle_language_server_message(call, id).await;
|
|
|
|
|
|
|
|
// limit render calls for fast language server messages
|
|
|
|
|
|
|
|
let last = self.editor.language_servers.incoming.is_empty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if last || self.last_render.elapsed() > LSP_DEADLINE {
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
self.last_render = Instant::now();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::DebuggerEvent(payload) => {
|
|
|
|
|
|
|
|
let needs_render = self.editor.handle_debugger_message(payload).await;
|
|
|
|
|
|
|
|
if needs_render {
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorEvent::IdleTimer => {
|
|
|
|
|
|
|
|
self.editor.clear_idle_timer();
|
|
|
|
|
|
|
|
self.handle_idle_timeout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn handle_terminal_events(&mut self, event: Result<CrosstermEvent, crossterm::ErrorKind>) {
|
|
|
|
pub fn handle_terminal_events(&mut self, event: Result<CrosstermEvent, crossterm::ErrorKind>) {
|
|
|
|
let mut cx = crate::compositor::Context {
|
|
|
|
let mut cx = crate::compositor::Context {
|
|
|
|
editor: &mut self.editor,
|
|
|
|
editor: &mut self.editor,
|
|
|
|