File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ pub struct CodeEditor {
105105 rows : usize ,
106106 vscroll : bool ,
107107 stick_to_bottom : bool ,
108- shrink : bool ,
108+ desired_width : f32 ,
109109}
110110
111111#[ cfg( feature = "editor" ) ]
@@ -130,7 +130,7 @@ impl Default for CodeEditor {
130130 rows : 10 ,
131131 vscroll : true ,
132132 stick_to_bottom : false ,
133- shrink : false ,
133+ desired_width : f32 :: INFINITY ,
134134 }
135135 }
136136}
@@ -198,7 +198,20 @@ impl CodeEditor {
198198 ///
199199 /// **Default: false**
200200 pub fn auto_shrink ( self , shrink : bool ) -> Self {
201- CodeEditor { shrink, ..self }
201+ CodeEditor {
202+ desired_width : if shrink { 0.0 } else { self . desired_width } ,
203+ ..self
204+ }
205+ }
206+
207+ /// Sets the desired width of the code editor
208+ ///
209+ /// **Default: `f32::INFINITY`**
210+ pub fn desired_width ( self , width : f32 ) -> Self {
211+ CodeEditor {
212+ desired_width : width,
213+ ..self
214+ }
202215 }
203216
204217 /// Stick to bottom
@@ -292,7 +305,7 @@ impl CodeEditor {
292305 . lock_focus ( true )
293306 . desired_rows ( self . rows )
294307 . frame ( true )
295- . desired_width ( if self . shrink { 0.0 } else { f32 :: MAX } )
308+ . desired_width ( self . desired_width )
296309 . layouter ( & mut layouter)
297310 . show ( ui) ;
298311 text_edit_output = Some ( output) ;
You can’t perform that action at this time.
0 commit comments