From 07e97e6cadd36ccb4c5e9a3e6cbb40266a057450 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 20 Jul 2021 15:30:50 -0700 Subject: [PATCH] wip --- zed/src/editor.rs | 4 ++++ zed/src/editor/display_map/wrap_map.rs | 10 +++++++++- zed/src/editor/element.rs | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/zed/src/editor.rs b/zed/src/editor.rs index d06b4611d4e2be94bb2c89092917296e34f7c1f3..9f9a0e955a71831580578d71125e192f5bf2a231 100644 --- a/zed/src/editor.rs +++ b/zed/src/editor.rs @@ -2190,6 +2190,10 @@ impl Editor { font_cache.em_width(font_id, settings.buffer_font_size) } + pub fn set_width(&self, width: f32) { + self.display_map.set_wrap_width(Some(width)); + } + // TODO: Can we make this not return a result? pub fn max_line_number_width( &self, diff --git a/zed/src/editor/display_map/wrap_map.rs b/zed/src/editor/display_map/wrap_map.rs index 8dfef04a112c04206ef5676b0c160b05694990b9..cf8cc1aa09809eb2b9cd9ec9f18b3daf1ee7fdbd 100644 --- a/zed/src/editor/display_map/wrap_map.rs +++ b/zed/src/editor/display_map/wrap_map.rs @@ -293,6 +293,14 @@ struct BackgroundWrapper { snapshot: Snapshot, } +enum WrapChange { + InputChange { + snapshot: InputSnapshot, + edits: Vec, + }, + WidthChange(Option), +} + impl BackgroundWrapper { fn new( snapshot: Snapshot, @@ -313,7 +321,7 @@ impl BackgroundWrapper { async fn run( &mut self, snapshot: InputSnapshot, - edits_rx: channel::Receiver<(InputSnapshot, Vec)>, + edits_rx: channel::Receiver, mut snapshot_tx: watch::Sender, ) { let edit = InputEdit { diff --git a/zed/src/editor/element.rs b/zed/src/editor/element.rs index 2921b2ce6afc3bdcec7beb4a1ddcfcbd8299a47a..70a254f0d5315df09d3b8efcb0e3279febd46b88 100644 --- a/zed/src/editor/element.rs +++ b/zed/src/editor/element.rs @@ -338,6 +338,8 @@ impl Element for EditorElement { } let view = self.view(app); + view.set_width(size.x()); + let font_cache = &cx.font_cache; let layout_cache = &cx.text_layout_cache; let line_height = view.line_height(font_cache);