Skip to content

Commit

Permalink
Ignore negative cursor positions
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo committed Dec 1, 2023
1 parent 6ccc333 commit f17ab10
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/bridge/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
fmt::{self, Debug},
};

use log::debug;
use log::{debug, warn};
use rmpv::Value;
use skia_safe::Color4f;

Expand Down Expand Up @@ -598,12 +598,19 @@ fn parse_grid_destroy(grid_destroy_arguments: Vec<Value>) -> Result<RedrawEvent>

fn parse_grid_cursor_goto(cursor_goto_arguments: Vec<Value>) -> Result<RedrawEvent> {
let [grid_id, row, column] = extract_values(cursor_goto_arguments)?;

Ok(RedrawEvent::CursorGoto {
grid: parse_u64(grid_id)?,
row: parse_u64(row)?,
column: parse_u64(column)?,
})
let validate = |v, field| {
(if v < 0 {
warn!("Negative cursor {field} received from Neovim {v}");
0
} else {
v
}) as u64
};
let grid = parse_u64(grid_id)?;
let row = validate(parse_i64(row)?, "row");
let column = validate(parse_i64(column)?, "column");

Ok(RedrawEvent::CursorGoto { grid, row, column })
}

fn parse_grid_scroll(grid_scroll_arguments: Vec<Value>) -> Result<RedrawEvent> {
Expand Down

0 comments on commit f17ab10

Please sign in to comment.