diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-08 20:22:29 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-08 20:22:29 +0200 |
| commit | 41d707480f2138a8a9b00b4efac4c87ed0eb79fc (patch) | |
| tree | 01d248347dc3d4f3b924d1e6949a88aaf1c63ced | |
| parent | b921d97334d116e38cb9650c126ef8f3c8763713 (diff) | |
change set_line api from table to string
| -rw-r--r-- | src/state/editor/mod.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/state/editor/mod.rs b/src/state/editor/mod.rs index d9c3ab5..3639226 100644 --- a/src/state/editor/mod.rs +++ b/src/state/editor/mod.rs @@ -3,7 +3,7 @@ use crate::cursor::CursorMove; use self::{bar::EditorBarState, buffer::Buffer, cursorshape::CursorShape}; use super::{window::Window, GlobalState, DUMMY_STATE}; -use mlua::{Lua, Table, UserData}; +use mlua::{Lua, UserData}; pub mod bar; pub mod buffer; @@ -85,15 +85,8 @@ impl UserData for EditorState { Ok(table) }); - fields.add_field_function_set("lines", |_, _, content: Table| { - let mut vec = Vec::new(); - - for r in content.pairs::<usize, String>() { - let (_, line) = r?; - vec.push(line); - } - - cfg_mut!().buffer.set_lines(vec); + fields.add_field_function_set("lines", |_, _, content: String| { + cfg_mut!().buffer.set_lines_from_string(content); Ok(()) }); |