| @@ -1215,6 +1215,7 @@ impl CodeActionsMenu { · 1214 unmodified lines |
| 1215 | 1215 | } |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | +#[derive(Debug)] |
| 1218 | 1219 | pub(crate) struct CopilotState { |
| 1219 | 1220 | excerpt_id: Option<ExcerptId>, |
| 1220 | 1221 | pending_refresh: Task<Option<()>>, |
| @@ -3114,7 +3115,7 @@ impl Editor { · 1893 unmodified lines |
| 3114 | 3115 | (InvalidationStrategy::RefreshRequested, None) |
| 3115 | 3116 | } else { |
| 3116 | 3117 | self.inlay_hint_cache.clear(); |
| 3117 | | − self.splice_inlay_hints( |
| 3118 | + self.splice_inlays( |
| 3118 | 3119 | self.visible_inlay_hints(cx) |
| 3119 | 3120 | .iter() |
| 3120 | 3121 | .map(|inlay| inlay.id) |
| @@ -3136,7 +3137,7 @@ impl Editor { · 15 unmodified lines |
| 3136 | 3137 | to_remove, |
| 3137 | 3138 | to_insert, |
| 3138 | 3139 | })) => { |
| 3139 | | − self.splice_inlay_hints(to_remove, to_insert, cx); |
| 3140 | + self.splice_inlays(to_remove, to_insert, cx); |
| 3140 | 3141 | return; |
| 3141 | 3142 | } |
| 3142 | 3143 | ControlFlow::Break(None) => return, |
| @@ -3149,7 +3150,7 @@ impl Editor { · 6 unmodified lines |
| 3149 | 3150 | to_insert, |
| 3150 | 3151 | }) = self.inlay_hint_cache.remove_excerpts(excerpts_removed) |
| 3151 | 3152 | { |
| 3152 | | − self.splice_inlay_hints(to_remove, to_insert, cx); |
| 3153 | + self.splice_inlays(to_remove, to_insert, cx); |
| 3153 | 3154 | } |
| 3154 | 3155 | return; |
| 3155 | 3156 | } |
| @@ -3172,7 +3173,7 @@ impl Editor { · 16 unmodified lines |
| 3172 | 3173 | ignore_debounce, |
| 3173 | 3174 | cx, |
| 3174 | 3175 | ) { |
| 3175 | | − self.splice_inlay_hints(to_remove, to_insert, cx); |
| 3176 | + self.splice_inlays(to_remove, to_insert, cx); |
| 3176 | 3177 | } |
| 3177 | 3178 | } |
| 3178 | 3179 | |
| @@ -3180,9 +3181,7 @@ impl Editor { · 1 unmodified line |
| 3180 | 3181 | self.display_map |
| 3181 | 3182 | .read(cx) |
| 3182 | 3183 | .current_inlays() |
| 3183 | | − .filter(move |inlay| { |
| 3184 | | − Some(inlay.id) != self.copilot_state.suggestion.as_ref().map(|h| h.id) |
| 3185 | | − }) |
| 3184 | + .filter(move |inlay| matches!(inlay.id, InlayId::Hint(_))) |
| 3186 | 3185 | .cloned() |
| 3187 | 3186 | .collect() |
| 3188 | 3187 | } |
| @@ -3253,7 +3252,7 @@ impl Editor { · 64 unmodified lines |
| 3253 | 3252 | } |
| 3254 | 3253 | } |
| 3255 | 3254 | |
| 3256 | | − fn splice_inlay_hints( |
| 3255 | + fn splice_inlays( |
| 3257 | 3256 | &self, |
| 3258 | 3257 | to_remove: Vec<InlayId>, |
| 3259 | 3258 | to_insert: Vec<Inlay>, |
| @@ -4161,7 +4160,10 @@ impl Editor { · 901 unmodified lines |
| 4161 | 4160 | } |
| 4162 | 4161 | |
| 4163 | 4162 | fn clear_copilot_suggestions(&mut self, cx: &mut ViewContext<Self>) { |
| 4164 | | − self.copilot_state = Default::default(); |
| 4163 | + if let Some(old_suggestion) = self.copilot_state.suggestion.take() { |
| 4164 | + self.splice_inlays(vec![old_suggestion.id], Vec::new(), cx); |
| 4165 | + } |
| 4166 | + self.copilot_state = CopilotState::default(); |
| 4165 | 4167 | self.discard_copilot_suggestion(cx); |
| 4166 | 4168 | } |
| 4167 | 4169 | |