Make autoscroll optional when highlighting editor rows (#11950)
Previously, when highlighting editor rows with a color, we always auto-scrolled to the first highlighted row. This was useful in contexts like go-to-line and the outline view. We had an explicit special case for git diff highlights. Now, part of the `highlight_rows` API, you specify whether or not you want the autoscroll behavior. This is needed because we want to highlight rows in the assistant panel, and we don't want the autoscroll. Release Notes: - N/A
This commit is contained in:
parent
57b5bff299
commit
4ca6e0e387
10 changed files with 86 additions and 95 deletions
|
@ -14,7 +14,6 @@ doctest = false
|
|||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
collections.workspace = true
|
||||
editor.workspace = true
|
||||
gpui.workspace = true
|
||||
menu.workspace = true
|
||||
|
|
|
@ -122,6 +122,7 @@ impl GoToLine {
|
|||
active_editor.highlight_rows::<GoToLineRowHighlights>(
|
||||
anchor..=anchor,
|
||||
Some(cx.theme().colors().editor_highlighted_line_background),
|
||||
true,
|
||||
cx,
|
||||
);
|
||||
active_editor.request_autoscroll(Autoscroll::center(), cx);
|
||||
|
@ -219,17 +220,14 @@ impl Render for GoToLine {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use collections::HashSet;
|
||||
use super::*;
|
||||
use gpui::{TestAppContext, VisualTestContext};
|
||||
use indoc::indoc;
|
||||
use project::{FakeFs, Project};
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
use workspace::{AppState, Workspace};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_go_to_line_view_row_highlights(cx: &mut TestAppContext) {
|
||||
init_test(cx);
|
||||
|
@ -350,7 +348,7 @@ mod tests {
|
|||
fn highlighted_display_rows(editor: &View<Editor>, cx: &mut VisualTestContext) -> Vec<u32> {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor
|
||||
.highlighted_display_rows(HashSet::default(), cx)
|
||||
.highlighted_display_rows(cx)
|
||||
.into_keys()
|
||||
.map(|r| r.0)
|
||||
.collect()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue