1
0
Fork 0
mirror of https://github.com/helix-editor/helix synced 2024-06-07 09:46:06 +02:00
This commit is contained in:
Blaž Hrastnik 2020-12-12 20:18:44 +09:00
parent ada3f92c5b
commit 29cb33300b

View File

@ -336,6 +336,7 @@ pub fn draw_and_swap(&mut self) {
.draw(self.cache.diff(&self.surface).into_iter());
// swap the buffer
std::mem::swap(&mut self.surface, &mut self.cache);
self.surface.reset(); // reset is faster than allocating new empty surface
}
pub fn render_cursor(&mut self, view: &View, prompt: Option<&Prompt>, viewport: Rect) {
@ -412,13 +413,6 @@ fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
commands::insert::insert_char(&mut cx, c);
}
}
Mode::Normal => {
if let Some(command) = self.keymap[&Mode::Normal].get(&keys) {
command(&mut cx);
// TODO: simplistic ensure cursor in view for now
}
}
mode => {
if let Some(command) = self.keymap[&mode].get(&keys) {
command(&mut cx);
@ -484,7 +478,6 @@ pub fn new(mut args: Args, executor: &'a smol::Executor<'a>) -> Result<Self, Err
}
fn render(&mut self) {
self.renderer.surface.reset(); // reset is faster than allocating new empty surface
let mut cx = crate::compositor::Context {
editor: &mut self.editor,
executor: &self.executor,
@ -543,6 +536,7 @@ pub fn handle_terminal_events(&mut self, event: Option<Result<Event, crossterm::
if should_redraw {
self.render();
// calling render twice here fixes it for some reason
}
}