Fix infinite loop in select all (#3154)
[[PR Description]] Release Notes: - Fixed an infinite loop in select all matches ([#2170](https://github.com/zed-industries/community/issues/2170)).
This commit is contained in:
commit
2b95db087b
4 changed files with 29 additions and 4 deletions
|
@ -6542,7 +6542,7 @@ impl Editor {
|
||||||
{
|
{
|
||||||
if selections
|
if selections
|
||||||
.iter()
|
.iter()
|
||||||
.find(|selection| selection.equals(&offset_range))
|
.find(|selection| selection.range().overlaps(&offset_range))
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
next_selected_range = Some(offset_range);
|
next_selected_range = Some(offset_range);
|
||||||
|
|
|
@ -731,7 +731,9 @@ mod tests {
|
||||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
surrounding_word(&snapshot, display_points[1]),
|
surrounding_word(&snapshot, display_points[1]),
|
||||||
display_points[0]..display_points[2]
|
display_points[0]..display_points[2],
|
||||||
|
"{}",
|
||||||
|
marked_text.to_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,7 +743,7 @@ mod tests {
|
||||||
assert("loremˇ ˇ ˇipsum", cx);
|
assert("loremˇ ˇ ˇipsum", cx);
|
||||||
assert("lorem\nˇˇˇ\nipsum", cx);
|
assert("lorem\nˇˇˇ\nipsum", cx);
|
||||||
assert("lorem\nˇˇipsumˇ", cx);
|
assert("lorem\nˇˇipsumˇ", cx);
|
||||||
assert("lorem,ˇˇ ˇipsum", cx);
|
assert("loremˇ,ˇˇ ipsum", cx);
|
||||||
assert("ˇloremˇˇ, ipsum", cx);
|
assert("ˇloremˇˇ, ipsum", cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -373,8 +373,8 @@ pub(crate) struct DiagnosticEndpoint {
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Debug)]
|
||||||
pub enum CharKind {
|
pub enum CharKind {
|
||||||
Punctuation,
|
|
||||||
Whitespace,
|
Whitespace,
|
||||||
|
Punctuation,
|
||||||
Word,
|
Word,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -734,3 +734,26 @@ async fn test_paragraphs_dont_wrap(cx: &mut gpui::TestAppContext) {
|
||||||
two"})
|
two"})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_select_all_issue_2170(cx: &mut gpui::TestAppContext) {
|
||||||
|
let mut cx = VimTestContext::new(cx, true).await;
|
||||||
|
|
||||||
|
cx.set_state(
|
||||||
|
indoc! {"
|
||||||
|
defmodule Test do
|
||||||
|
def test(a, ˇ[_, _] = b), do: IO.puts('hi')
|
||||||
|
end
|
||||||
|
"},
|
||||||
|
Mode::Normal,
|
||||||
|
);
|
||||||
|
cx.simulate_keystrokes(["g", "a"]);
|
||||||
|
cx.assert_state(
|
||||||
|
indoc! {"
|
||||||
|
defmodule Test do
|
||||||
|
def test(a, «[ˇ»_, _] = b), do: IO.puts('hi')
|
||||||
|
end
|
||||||
|
"},
|
||||||
|
Mode::Visual,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue