1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-08 00:15:50 +03:00

keep undo history on closing search box in editor example

Этот коммит содержится в:
rhysd
2022-07-08 10:12:49 +09:00
родитель 8008c0ebda
Коммит 7bc9a959f2

Просмотреть файл

@@ -15,7 +15,7 @@ use tui::style::{Color, Modifier, Style};
use tui::text::{Span, Spans}; use tui::text::{Span, Spans};
use tui::widgets::{Block, Borders, Paragraph}; use tui::widgets::{Block, Borders, Paragraph};
use tui::Terminal; use tui::Terminal;
use tui_textarea::{Input, Key, TextArea}; use tui_textarea::{CursorMove, Input, Key, TextArea};
macro_rules! error { macro_rules! error {
($fmt: expr $(, $args:tt)*) => {{ ($fmt: expr $(, $args:tt)*) => {{
@@ -46,9 +46,10 @@ impl<'a> SearchBox<'a> {
fn close(&mut self) { fn close(&mut self) {
self.open = false; self.open = false;
let block = self.textarea.block().unwrap().clone(); // Remove input for next search. Do not recreate `self.textarea` instance to keep undo history so that users can
self.textarea = TextArea::default(); // restore previous input easily.
self.textarea.set_block(block); self.textarea.move_cursor(CursorMove::End);
self.textarea.delete_line_by_head();
} }
fn height(&self) -> u16 { fn height(&self) -> u16 {