| @@ -171,173 +171,170 @@ pub fn update_inlay_link_and_hover_points( · 170 unmodified lines |
| 171 | shift_held: bool, | 171 | shift_held: bool, |
| 172 | cx: &mut ViewContext<'_, Editor>, | 172 | cx: &mut ViewContext<'_, Editor>, |
| 173 | ) { | 173 | ) { |
| 174 | todo!("old implementation below") | 174 | let hovered_offset = if point_for_position.column_overshoot_after_line_end == 0 { |
| 175 | } | 175 | Some(snapshot.display_point_to_inlay_offset(point_for_position.exact_unclipped, Bias::Left)) |
| 176 | // ) { | 176 | } else { |
| 177 | // let hovered_offset = if point_for_position.column_overshoot_after_line_end == 0 { | 177 | None |
| 178 | // Some(snapshot.display_point_to_inlay_offset(point_for_position.exact_unclipped, Bias::Left)) | 178 | }; |
| 179 | // } else { | 179 | let mut go_to_definition_updated = false; |
| 180 | // None | 180 | let mut hover_updated = false; |
| 181 | // }; | 181 | if let Some(hovered_offset) = hovered_offset { |
| 182 | // let mut go_to_definition_updated = false; | 182 | let buffer_snapshot = editor.buffer().read(cx).snapshot(cx); |
| 183 | // let mut hover_updated = false; | 183 | let previous_valid_anchor = buffer_snapshot.anchor_at( |
| 184 | // if let Some(hovered_offset) = hovered_offset { | 184 | point_for_position.previous_valid.to_point(snapshot), |
| 185 | // let buffer_snapshot = editor.buffer().read(cx).snapshot(cx); | 185 | Bias::Left, |
| 186 | // let previous_valid_anchor = buffer_snapshot.anchor_at( | 186 | ); |
| 187 | // point_for_position.previous_valid.to_point(snapshot), | 187 | let next_valid_anchor = buffer_snapshot.anchor_at( |
| 188 | // Bias::Left, | 188 | point_for_position.next_valid.to_point(snapshot), |
| 189 | // ); | 189 | Bias::Right, |
| 190 | // let next_valid_anchor = buffer_snapshot.anchor_at( | 190 | ); |
| 191 | // point_for_position.next_valid.to_point(snapshot), | 191 | if let Some(hovered_hint) = editor |
| 192 | // Bias::Right, | 192 | .visible_inlay_hints(cx) |
| 193 | // ); | 193 | .into_iter() |
| 194 | // if let Some(hovered_hint) = editor | 194 | .skip_while(|hint| { |
| 195 | // .visible_inlay_hints(cx) | 195 | hint.position |
| 196 | // .into_iter() | 196 | .cmp(&previous_valid_anchor, &buffer_snapshot) |
| 197 | // .skip_while(|hint| { | 197 | .is_lt() |
| 198 | // hint.position | 198 | }) |
| 199 | // .cmp(&previous_valid_anchor, &buffer_snapshot) | 199 | .take_while(|hint| { |
| 200 | // .is_lt() | 200 | hint.position |
| 201 | // }) | 201 | .cmp(&next_valid_anchor, &buffer_snapshot) |
| 202 | // .take_while(|hint| { | 202 | .is_le() |
| 203 | // hint.position | 203 | }) |
| 204 | // .cmp(&next_valid_anchor, &buffer_snapshot) | 204 | .max_by_key(|hint| hint.id) |
| 205 | // .is_le() | 205 | { |
| 206 | // }) | 206 | let inlay_hint_cache = editor.inlay_hint_cache(); |
| 207 | // .max_by_key(|hint| hint.id) | 207 | let excerpt_id = previous_valid_anchor.excerpt_id; |
| 208 | // { | 208 | if let Some(cached_hint) = inlay_hint_cache.hint_by_id(excerpt_id, hovered_hint.id) { |
| 209 | // let inlay_hint_cache = editor.inlay_hint_cache(); | 209 | match cached_hint.resolve_state { |
| 210 | // let excerpt_id = previous_valid_anchor.excerpt_id; | 210 | ResolveState::CanResolve(_, _) => { |
| 211 | // if let Some(cached_hint) = inlay_hint_cache.hint_by_id(excerpt_id, hovered_hint.id) { | 211 | if let Some(buffer_id) = previous_valid_anchor.buffer_id { |
| 212 | // match cached_hint.resolve_state { | 212 | inlay_hint_cache.spawn_hint_resolve( |
| 213 | // ResolveState::CanResolve(_, _) => { | 213 | buffer_id, |
| 214 | // if let Some(buffer_id) = previous_valid_anchor.buffer_id { | 214 | excerpt_id, |
| 215 | // inlay_hint_cache.spawn_hint_resolve( | 215 | hovered_hint.id, |
| 216 | // buffer_id, | 216 | cx, |
| 217 | // excerpt_id, | 217 | ); |
| 218 | // hovered_hint.id, | 218 | } |
| 219 | // cx, | 219 | } |
| 220 | // ); | 220 | ResolveState::Resolved => { |
| 221 | // } | 221 | let mut extra_shift_left = 0; |
| 222 | // } | 222 | let mut extra_shift_right = 0; |
| 223 | // ResolveState::Resolved => { | 223 | if cached_hint.padding_left { |
| 224 | // let mut extra_shift_left = 0; | 224 | extra_shift_left += 1; |
| 225 | // let mut extra_shift_right = 0; | 225 | extra_shift_right += 1; |
| 226 | // if cached_hint.padding_left { | 226 | } |
| 227 | // extra_shift_left += 1; | 227 | if cached_hint.padding_right { |
| 228 | // extra_shift_right += 1; | 228 | extra_shift_right += 1; |
| 229 | // } | 229 | } |
| 230 | // if cached_hint.padding_right { | 230 | match cached_hint.label { |
| 231 | // extra_shift_right += 1; | 231 | project::InlayHintLabel::String(_) => { |
| 232 | // } | 232 | if let Some(tooltip) = cached_hint.tooltip { |
| 233 | // match cached_hint.label { | 233 | hover_popover::hover_at_inlay( |
| 234 | // project::InlayHintLabel::String(_) => { | 234 | editor, |
| 235 | // if let Some(tooltip) = cached_hint.tooltip { | 235 | InlayHover { |
| 236 | // hover_popover::hover_at_inlay( | 236 | excerpt: excerpt_id, |
| 237 | // editor, | 237 | tooltip: match tooltip { |
| 238 | // InlayHover { | 238 | InlayHintTooltip::String(text) => HoverBlock { |
| 239 | // excerpt: excerpt_id, | 239 | text, |
| 240 | // tooltip: match tooltip { | 240 | kind: HoverBlockKind::PlainText, |
| 241 | // InlayHintTooltip::String(text) => HoverBlock { | 241 | }, |
| 242 | // text, | 242 | InlayHintTooltip::MarkupContent(content) => { |
| 243 | // kind: HoverBlockKind::PlainText, | 243 | HoverBlock { |
| 244 | // }, | 244 | text: content.value, |
| 245 | // InlayHintTooltip::MarkupContent(content) => { | 245 | kind: content.kind, |
| 246 | // HoverBlock { | 246 | } |
| 247 | // text: content.value, | 247 | } |
| 248 | // kind: content.kind, | 248 | }, |
| 249 | // } | 249 | range: InlayHighlight { |
| 250 | // } | 250 | inlay: hovered_hint.id, |
| 251 | // }, | 251 | inlay_position: hovered_hint.position, |
| 252 | // range: InlayHighlight { | 252 | range: extra_shift_left |
| 253 | // inlay: hovered_hint.id, | 253 | ..hovered_hint.text.len() + extra_shift_right, |
| 254 | // inlay_position: hovered_hint.position, | 254 | }, |
| 255 | // range: extra_shift_left | 255 | }, |
| 256 | // ..hovered_hint.text.len() + extra_shift_right, | 256 | cx, |
| 257 | // }, | 257 | ); |
| 258 | // }, | 258 | hover_updated = true; |
| 259 | // cx, | 259 | } |
| 260 | // ); | 260 | } |
| 261 | // hover_updated = true; | 261 | project::InlayHintLabel::LabelParts(label_parts) => { |
| 262 | // } | 262 | let hint_start = |
| 263 | // } | 263 | snapshot.anchor_to_inlay_offset(hovered_hint.position); |
| 264 | // project::InlayHintLabel::LabelParts(label_parts) => { | 264 | if let Some((hovered_hint_part, part_range)) = |
| 265 | // let hint_start = | 265 | hover_popover::find_hovered_hint_part( |
| 266 | // snapshot.anchor_to_inlay_offset(hovered_hint.position); | 266 | label_parts, |
| 267 | // if let Some((hovered_hint_part, part_range)) = | 267 | hint_start, |
| 268 | // hover_popover::find_hovered_hint_part( | 268 | hovered_offset, |
| 269 | // label_parts, | 269 | ) |
| 270 | // hint_start, | 270 | { |
| 271 | // hovered_offset, | 271 | let highlight_start = |
| 272 | // ) | 272 | (part_range.start - hint_start).0 + extra_shift_left; |
| 273 | // { | 273 | let highlight_end = |
| 274 | // let highlight_start = | 274 | (part_range.end - hint_start).0 + extra_shift_right; |
| 275 | // (part_range.start - hint_start).0 + extra_shift_left; | 275 | let highlight = InlayHighlight { |
| 276 | // let highlight_end = | 276 | inlay: hovered_hint.id, |
| 277 | // (part_range.end - hint_start).0 + extra_shift_right; | 277 | inlay_position: hovered_hint.position, |
| 278 | // let highlight = InlayHighlight { | 278 | range: highlight_start..highlight_end, |
| 279 | // inlay: hovered_hint.id, | 279 | }; |
| 280 | // inlay_position: hovered_hint.position, | 280 | if let Some(tooltip) = hovered_hint_part.tooltip { |
| 281 | // range: highlight_start..highlight_end, | 281 | hover_popover::hover_at_inlay( |
| 282 | // }; | 282 | editor, |
| 283 | // if let Some(tooltip) = hovered_hint_part.tooltip { | 283 | InlayHover { |
| 284 | // hover_popover::hover_at_inlay( | 284 | excerpt: excerpt_id, |
| 285 | // editor, | 285 | tooltip: match tooltip { |
| 286 | // InlayHover { | 286 | InlayHintLabelPartTooltip::String(text) => { |
| 287 | // excerpt: excerpt_id, | 287 | HoverBlock { |
| 288 | // tooltip: match tooltip { | 288 | text, |
| 289 | // InlayHintLabelPartTooltip::String(text) => { | 289 | kind: HoverBlockKind::PlainText, |
| 290 | // HoverBlock { | 290 | } |
| 291 | // text, | 291 | } |
| 292 | // kind: HoverBlockKind::PlainText, | 292 | InlayHintLabelPartTooltip::MarkupContent( |
| 293 | // } | 293 | content, |
| 294 | // } | 294 | ) => HoverBlock { |
| 295 | // InlayHintLabelPartTooltip::MarkupContent( | 295 | text: content.value, |
| 296 | // content, | 296 | kind: content.kind, |
| 297 | // ) => HoverBlock { | 297 | }, |
| 298 | // text: content.value, | 298 | }, |
| 299 | // kind: content.kind, | 299 | range: highlight.clone(), |
| 300 | // }, | 300 | }, |
| 301 | // }, | 301 | cx, |
| 302 | // range: highlight.clone(), | 302 | ); |
| 303 | // }, | 303 | hover_updated = true; |
| 304 | // cx, | 304 | } |
| 305 | // ); | 305 | if let Some((language_server_id, location)) = |
| 306 | // hover_updated = true; | 306 | hovered_hint_part.location |
| 307 | // } | 307 | { |
| 308 | // if let Some((language_server_id, location)) = | 308 | go_to_definition_updated = true; |
| 309 | // hovered_hint_part.location | 309 | update_go_to_definition_link( |
| 310 | // { | 310 | editor, |
| 311 | // go_to_definition_updated = true; | 311 | Some(GoToDefinitionTrigger::InlayHint( |
| 312 | // update_go_to_definition_link( | 312 | highlight, |
| 313 | // editor, | 313 | location, |
| 314 | // Some(GoToDefinitionTrigger::InlayHint( | 314 | language_server_id, |
| 315 | // highlight, | 315 | )), |
| 316 | // location, | 316 | cmd_held, |
| 317 | // language_server_id, | 317 | shift_held, |
| 318 | // )), | 318 | cx, |
| 319 | // cmd_held, | 319 | ); |
| 320 | // shift_held, | 320 | } |
| 321 | // cx, | 321 | } |
| 322 | // ); | 322 | } |
| 323 | // } | 323 | }; |
| 324 | // } | 324 | } |
| 325 | // } | 325 | ResolveState::Resolving => {} |
| 326 | // }; | 326 | } |
| 327 | // } | 327 | } |
| 328 | // ResolveState::Resolving => {} | 328 | } |
| 329 | // } | 329 | } |
| 330 | // } | | |
| 331 | // } | | |
| 332 | // } | | |
| 333 | | 330 | |
| 334 | // if !go_to_definition_updated { | 331 | if !go_to_definition_updated { |
| 335 | // update_go_to_definition_link(editor, None, cmd_held, shift_held, cx); | 332 | update_go_to_definition_link(editor, None, cmd_held, shift_held, cx); |
| 336 | // } | 333 | } |
| 337 | // if !hover_updated { | 334 | if !hover_updated { |
| 338 | // hover_popover::hover_at(editor, None, cx); | 335 | hover_popover::hover_at(editor, None, cx); |
| 339 | // } | 336 | } |
| 340 | // } | 337 | } |
| 341 | | 338 | |
| 342 | #[derive(Debug, Clone, Copy, PartialEq)] | 339 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 343 | pub enum LinkDefinitionKind { | 340 | pub enum LinkDefinitionKind { |