don't request timer if blink interval is 0
@@ -544,8 +544,12 @@ fn event(
Event::Command(cmd) if cmd.is(LAPCE_UI_COMMAND) => {
let command = cmd.get_unchecked(LAPCE_UI_COMMAND);
if let LapceUICommand::Focus = command {
- self.cursor_blink_timer =
- ctx.request_timer(Duration::from_millis(500), None);
+ if data.config.editor.blink_interval > 0 {
+ self.cursor_blink_timer = ctx.request_timer(
+ Duration::from_millis(data.config.editor.blink_interval),
+ None,
+ );
+ }
self.request_focus(ctx, data, true);
let editor_data = data.editor_view_content(self.view_id);
self.ensure_cursor_visible(
@@ -559,14 +563,18 @@ fn event(
}
Event::Timer(id) if self.cursor_blink_timer == *id => {
ctx.set_handled();
+ if data.config.editor.blink_interval > 0 {
if ctx.is_focused() {
ctx.request_paint();
- self.cursor_blink_timer =
- ctx.request_timer(Duration::from_millis(500), None);
+ self.cursor_blink_timer = ctx.request_timer(
+ Duration::from_millis(data.config.editor.blink_interval),
+ None,
+ );
} else {
self.cursor_blink_timer = TimerToken::INVALID;
}
}
+ }
Event::Timer(id) if self.last_idle_timer == *id => {
ctx.set_handled();
let editor_data = data.editor_view_content(self.view_id);
@@ -768,6 +776,7 @@ fn update(
}
}
+ if data.config.editor.blink_interval > 0 {
if data.focus == self.view_id {
let reset = if old_data.focus != self.view_id {
true
@@ -784,13 +793,16 @@ fn update(
};
if reset {
- self.cursor_blink_timer =
- ctx.request_timer(Duration::from_millis(500), None);
+ self.cursor_blink_timer = ctx.request_timer(
+ Duration::from_millis(data.config.editor.blink_interval),
+ None,
+ );
*editor_data.editor.last_cursor_instant.borrow_mut() =
Instant::now();
ctx.request_paint();
}
}
+ }
if old_data.config.lapce.modal != data.config.lapce.modal
&& !editor_data.doc.content().is_input()
