From 41d707480f2138a8a9b00b4efac4c87ed0eb79fc Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 8 Aug 2024 20:22:29 +0200 Subject: change set_line api from table to string --- src/state/editor/mod.rs | 13 +++---------- 1 file 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::() { - 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(()) }); -- cgit v1.2.3-70-g09d2