Speed optimization

don't update im_location on every curosr_goto event
This commit is contained in:
daa 2018-04-29 15:12:04 +03:00
parent 986e587547
commit 049d653b6e
2 changed files with 11 additions and 1 deletions

View File

@ -194,6 +194,7 @@ fn call_redraw_handler(
}
ui.on_redraw(&repaint_mode);
ui.redraw_handler_finish();
Ok(())
}

View File

@ -124,6 +124,7 @@ pub struct State {
pub drawing_area: gtk::DrawingArea,
tabs: Tabline,
im_context: gtk::IMMulticontext,
update_im_location: bool,
error_area: error::ErrorArea,
options: ShellOptions,
@ -169,6 +170,7 @@ impl State {
drawing_area,
tabs: Tabline::new(),
im_context: gtk::IMMulticontext::new(),
update_im_location: false,
error_area: error::ErrorArea::new(),
options,
@ -1164,9 +1166,16 @@ fn init_nvim(state_ref: &Arc<UiMutex<State>>) {
// Neovim redraw events
impl State {
pub fn redraw_handler_finish(&mut self) {
if self.update_im_location {
self.set_im_location();
self.update_im_location = false;
}
}
pub fn on_cursor_goto(&mut self, row: u64, col: u64) -> RepaintMode {
let repaint_area = self.model.set_cursor(row as usize, col as usize);
self.set_im_location();
self.update_im_location = true;
RepaintMode::AreaList(repaint_area)
}