Skip to content

Commit 295aae4

Browse files
authored
Merge pull request #2513 from ayeniswe/feat/set-width_text-editor
feat: add width setter for Text-Editor widget
2 parents f392f4a + 7c7e94c commit 295aae4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

widget/src/text_editor.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ where
109109
self
110110
}
111111

112+
/// Sets the width of the [`TextEditor`].
113+
pub fn width(mut self, width: impl Into<Pixels>) -> Self {
114+
self.width = Length::from(width.into());
115+
self
116+
}
117+
112118
/// Sets the message that should be produced when some action is performed in
113119
/// the [`TextEditor`].
114120
///
@@ -498,7 +504,7 @@ where
498504
state.highlighter_settings = self.highlighter_settings.clone();
499505
}
500506

501-
let limits = limits.height(self.height);
507+
let limits = limits.width(self.width).height(self.height);
502508

503509
internal.editor.update(
504510
limits.shrink(self.padding).max(),

0 commit comments

Comments
 (0)