Unified · Split
| @@ -1196,6 +1196,7 @@ enum GotoDefinitionKind { · 1195 unmodified lines | ||
| 1196 | 1196 | #[derive(Debug, Copy, Clone)] |
| 1197 | 1197 | enum InlayRefreshReason { |
| 1198 | 1198 | SettingsChange(editor_settings::InlayHints), |
| 1199 | + Scroll(ScrollAnchor), | |
| 1199 | 1200 | VisibleExcerptsChange, |
| 1200 | 1201 | } |
| 1201 | 1202 | |
| @@ -2624,6 +2625,34 @@ impl Editor { · 1422 unmodified lines | ||
| 2624 | 2625 | InlayRefreshReason::SettingsChange(new_settings) => self |
| 2625 | 2626 | .inlay_hint_cache |
| 2626 | 2627 | .spawn_settings_update(multi_buffer_handle, new_settings, current_inlays), |
| 2628 | + InlayRefreshReason::Scroll(scrolled_to) => { | |
| 2629 | + if let Some(new_query) = self | |
| 2630 | + .excerpt_visible_offsets(&multi_buffer_handle, cx) | |
| 2631 | + .into_iter() | |
| 2632 | + .find_map(|(buffer, _, excerpt_id)| { | |
| 2633 | + let buffer_id = scrolled_to.anchor.buffer_id?; | |
| 2634 | + if buffer_id == buffer.read(cx).remote_id() | |
| 2635 | + && scrolled_to.anchor.excerpt_id == excerpt_id | |
| 2636 | + { | |
| 2637 | + Some(InlayHintQuery { | |
| 2638 | + buffer_id, | |
| 2639 | + buffer_version: buffer.read(cx).version(), | |
| 2640 | + excerpt_id, | |
| 2641 | + }) | |
| 2642 | + } else { | |
| 2643 | + None | |
| 2644 | + } | |
| 2645 | + }) | |
| 2646 | + { | |
| 2647 | + self.inlay_hint_cache.spawn_hints_update( | |
| 2648 | + multi_buffer_handle, | |
| 2649 | + vec![new_query], | |
| 2650 | + current_inlays, | |
| 2651 | + false, | |
| 2652 | + cx, | |
| 2653 | + ) | |
| 2654 | + } | |
| 2655 | + } | |
| 2627 | 2656 | InlayRefreshReason::VisibleExcerptsChange => { |
| 2628 | 2657 | let replacement_queries = self |
| 2629 | 2658 | .excerpt_visible_offsets(&multi_buffer_handle, cx) |
| @@ -2632,7 +2661,7 @@ impl Editor { · 2 unmodified lines | ||
| 2632 | 2661 | let buffer = buffer.read(cx); |
| 2633 | 2662 | InlayHintQuery { |
| 2634 | 2663 | buffer_id: buffer.remote_id(), |
| 2635 | − buffer_version: buffer.version.clone(), | |
| 2664 | + buffer_version: buffer.version(), | |
| 2636 | 2665 | excerpt_id, |
| 2637 | 2666 | } |
| 2638 | 2667 | }) |
| @@ -2641,6 +2670,7 @@ impl Editor { · 2 unmodified lines | ||
| 2641 | 2670 | multi_buffer_handle, |
| 2642 | 2671 | replacement_queries, |
| 2643 | 2672 | current_inlays, |
| 2673 | + true, | |
| 2644 | 2674 | cx, |
| 2645 | 2675 | ) |
| 2646 | 2676 | } |
| @@ -102,27 +102,29 @@ impl InlayHintCache { · 101 unmodified lines | ||
| 102 | 102 | multi_buffer: ModelHandle<MultiBuffer>, |
| 103 | 103 | queries: Vec<InlayHintQuery>, |
| 104 | 104 | current_inlays: Vec<Inlay>, |
| 105 | + conflicts_invalidate_cache: bool, | |
| 105 | 106 | cx: &mut ViewContext<Editor>, |
| 106 | 107 | ) { |
| 107 | − let conflicts_with_cache = queries.iter().any(|update_query| { | |
| 108 | − let Some(cached_buffer_hints) = self.hints_in_buffers.get(&update_query.buffer_id) | |
| 108 | + let conflicts_with_cache = conflicts_invalidate_cache | |
| 109 | + && queries.iter().any(|update_query| { | |
| 110 | + let Some(cached_buffer_hints) = self.hints_in_buffers.get(&update_query.buffer_id) | |
| 109 | 111 | else { return false }; |
| 110 | − if cached_buffer_hints | |
| 111 | − .buffer_version | |
| 112 | − .changed_since(&update_query.buffer_version) | |
| 113 | − { | |
| 114 | − false | |
| 115 | − } else if update_query | |
| 116 | − .buffer_version | |
| 117 | − .changed_since(&cached_buffer_hints.buffer_version) | |
| 118 | − { | |
| 119 | − true | |
| 120 | − } else { | |
| 121 | − cached_buffer_hints | |
| 122 | − .hints_per_excerpt | |
| 123 | − .contains_key(&update_query.excerpt_id) | |
| 124 | − } | |
| 125 | − }); | |
| 112 | + if cached_buffer_hints | |
| 113 | + .buffer_version | |
| 114 | + .changed_since(&update_query.buffer_version) | |
| 115 | + { | |
| 116 | + false | |
| 117 | + } else if update_query | |
| 118 | + .buffer_version | |
| 119 | + .changed_since(&cached_buffer_hints.buffer_version) | |
| 120 | + { | |
| 121 | + true | |
| 122 | + } else { | |
| 123 | + cached_buffer_hints | |
| 124 | + .hints_per_excerpt | |
| 125 | + .contains_key(&update_query.excerpt_id) | |
| 126 | + } | |
| 127 | + }); | |
| 126 | 128 | |
| 127 | 129 | let queries_per_buffer = queries |
| 128 | 130 | .into_iter() |
| @@ -569,7 +571,6 @@ fn allowed_hint_types( · 440 unmodified lines | ||
| 569 | 571 | } |
| 570 | 572 | |
| 571 | 573 | // TODO kb wrong, query and update the editor separately |
| 572 | −// TODO kb need to react on react on scrolling too, for multibuffer excerpts | |
| 573 | 574 | fn fetch_queries( |
| 574 | 575 | multi_buffer: ModelHandle<MultiBuffer>, |
| 575 | 576 | queries: impl Iterator<Item = InlayHintQuery>, |
| @@ -13,7 +13,7 @@ use gpui::{ · 12 unmodified lines | ||
| 13 | 13 | }; |
| 14 | 14 | use language::{Bias, Point}; |
| 15 | 15 | use util::ResultExt; |
| 16 | −use workspace::WorkspaceId; | |
| 16 | +use workspace::{item::Item, WorkspaceId}; | |
| 17 | 17 | |
| 18 | 18 | use crate::{ |
| 19 | 19 | display_map::{DisplaySnapshot, ToDisplayPoint}, |
| @@ -176,7 +176,7 @@ impl ScrollManager { · 156 unmodified lines | ||
| 176 | 176 | autoscroll: bool, |
| 177 | 177 | workspace_id: Option<i64>, |
| 178 | 178 | cx: &mut ViewContext<Editor>, |
| 179 | − ) { | |
| 179 | + ) -> ScrollAnchor { | |
| 180 | 180 | let (new_anchor, top_row) = if scroll_position.y() <= 0. { |
| 181 | 181 | ( |
| 182 | 182 | ScrollAnchor { |
| @@ -205,6 +205,7 @@ impl ScrollManager { · 22 unmodified lines | ||
| 205 | 205 | }; |
| 206 | 206 | |
| 207 | 207 | self.set_anchor(new_anchor, top_row, local, autoscroll, workspace_id, cx); |
| 208 | + new_anchor | |
| 208 | 209 | } |
| 209 | 210 | |
| 210 | 211 | fn set_anchor( |
| @@ -312,7 +313,7 @@ impl Editor { · 101 unmodified lines | ||
| 312 | 313 | |
| 313 | 314 | hide_hover(self, cx); |
| 314 | 315 | let workspace_id = self.workspace.as_ref().map(|workspace| workspace.1); |
| 315 | − self.scroll_manager.set_scroll_position( | |
| 316 | + let scroll_anchor = self.scroll_manager.set_scroll_position( | |
| 316 | 317 | scroll_position, |
| 317 | 318 | &map, |
| 318 | 319 | local, |
| @@ -320,6 +321,10 @@ impl Editor { · 1 unmodified line | ||
| 320 | 321 | workspace_id, |
| 321 | 322 | cx, |
| 322 | 323 | ); |
| 324 | + | |
| 325 | + if !self.is_singleton(cx) { | |
| 326 | + self.refresh_inlays(crate::InlayRefreshReason::Scroll(scroll_anchor), cx); | |
| 327 | + } | |
| 323 | 328 | } |
| 324 | 329 | |
| 325 | 330 | pub fn scroll_position(&self, cx: &mut ViewContext<Self>) -> Vector2F { |