Skip to content

Commit

Permalink
Move prev_text off of the widget struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndarilek committed May 19, 2021
1 parent 7c19047 commit ea79d59
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions egui/src/widgets/text_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ impl CCursorPair {
#[derive(Debug)]
pub struct TextEdit<'t> {
text: &'t mut String,
prev_text: String,
hint_text: String,
id: Option<Id>,
id_source: Option<Id>,
Expand Down Expand Up @@ -171,7 +170,6 @@ impl<'t> TextEdit<'t> {
pub fn singleline(text: &'t mut String) -> Self {
TextEdit {
text,
prev_text: Default::default(),
hint_text: Default::default(),
id: None,
id_source: None,
Expand All @@ -191,7 +189,6 @@ impl<'t> TextEdit<'t> {
pub fn multiline(text: &'t mut String) -> Self {
TextEdit {
text,
prev_text: Default::default(),
hint_text: Default::default(),
id: None,
id_source: None,
Expand Down Expand Up @@ -334,7 +331,6 @@ impl<'t> Widget for TextEdit<'t> {
impl<'t> TextEdit<'t> {
fn content_ui(self, ui: &mut Ui) -> Response {
let TextEdit {
mut prev_text,
text,
hint_text,
id,
Expand All @@ -350,6 +346,7 @@ impl<'t> TextEdit<'t> {
lock_focus,
} = self;

let mut prev_text = text.clone();
let text_style = text_style.unwrap_or_else(|| ui.style().body_text_style);
let line_spacing = ui.fonts().row_height(text_style);
let available_width = ui.available_width();
Expand Down Expand Up @@ -556,7 +553,6 @@ impl<'t> TextEdit<'t> {
if let Some((undo_ccursorp, undo_txt)) =
state.undoer.undo(&(cursorp.as_ccursorp(), text.clone()))
{
prev_text = text.clone();
*text = undo_txt.clone();
Some(*undo_ccursorp)
} else {
Expand Down

0 comments on commit ea79d59

Please sign in to comment.