@@ -10187,6 +10187,71 @@ mod tests {
use std::num::NonZeroU32;
use util::test::sample_text;
+ #[gpui::test]
+ async fn test_soft_wrap_editor_width_auto_height_editor(cx: &mut TestAppContext) {
+ init_test(cx, |_| {});
+
+ let window = cx.add_window(|window, cx| {
+ let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), cx);
+ let mut editor = Editor::new(
+ EditorMode::AutoHeight {
+ min_lines: 1,
+ max_lines: None,
+ },
+ buffer,
+ None,
+ window,
+ cx,
+ );
+ editor.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);
+ editor
+ });
+ let cx = &mut VisualTestContext::from_window(*window, cx);
+ let editor = window.root(cx).unwrap();
+ let style = cx.update(|_, cx| editor.read(cx).style().unwrap().clone());
+
+ for x in 1..=100 {
+ let (_, state) = cx.draw(
+ Default::default(),
+ size(px(200. + 0.13 * x as f32), px(500.)),
+ |_, _| EditorElement::new(&editor, style.clone()),
+ );
+
+ assert!(
+ state.position_map.scroll_max.x == 0.,
+ "Soft wrapped editor should have no horizontal scrolling!"
+ );
+ }
+ }
+
+ #[gpui::test]
+ async fn test_soft_wrap_editor_width_full_editor(cx: &mut TestAppContext) {
+ init_test(cx, |_| {});
+
+ let window = cx.add_window(|window, cx| {
+ let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), cx);
+ let mut editor = Editor::new(EditorMode::full(), buffer, None, window, cx);
+ editor.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);
+ editor
+ });
+ let cx = &mut VisualTestContext::from_window(*window, cx);
+ let editor = window.root(cx).unwrap();
+ let style = cx.update(|_, cx| editor.read(cx).style().unwrap().clone());
+
+ for x in 1..=100 {
+ let (_, state) = cx.draw(
+ Default::default(),
+ size(px(200. + 0.13 * x as f32), px(500.)),
+ |_, _| EditorElement::new(&editor, style.clone()),
+ );
+
+ assert!(
+ state.position_map.scroll_max.x == 0.,
+ "Soft wrapped editor should have no horizontal scrolling!"
+ );
+ }
+ }
+
#[gpui::test]
fn test_shape_line_numbers(cx: &mut TestAppContext) {
init_test(cx, |_| {});