Skip to content

Commit

Permalink
Merge pull request #2513 from ayeniswe/feat/set-width_text-editor
Browse files Browse the repository at this point in the history
feat: add width setter for Text-Editor widget
  • Loading branch information
hecrj authored Sep 12, 2024
2 parents f392f4a + 7c7e94c commit 295aae4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion widget/src/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ where
self
}

/// Sets the width of the [`TextEditor`].
pub fn width(mut self, width: impl Into<Pixels>) -> Self {
self.width = Length::from(width.into());
self
}

/// Sets the message that should be produced when some action is performed in
/// the [`TextEditor`].
///
Expand Down Expand Up @@ -498,7 +504,7 @@ where
state.highlighter_settings = self.highlighter_settings.clone();
}

let limits = limits.height(self.height);
let limits = limits.width(self.width).height(self.height);

internal.editor.update(
limits.shrink(self.padding).max(),
Expand Down

0 comments on commit 295aae4

Please sign in to comment.