Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim: Add basic mark support #11507

Merged
merged 4 commits into from
May 10, 2024
Merged

Conversation

Zachiah
Copy link
Contributor

@Zachiah Zachiah commented May 7, 2024

Release Notes:

  • vim: Added support for buffer-local marks ('a-'z) and some builtin marks '<,'>,'[,'], '{, '} and ^. Global marks ('A-'Z), and other builtin marks ('0-'9, '(, '), '', '., '") are not yet implemented. (vim-mode support for marks #5122)

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 7, 2024
@zed-industries-bot
Copy link

zed-industries-bot commented May 7, 2024

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- (Added|Fixed|Improved) ... ([#<public_issue_number_if_exists>](https://github.com/zed-industries/zed/issues/<public_issue_number_if_exists>)).

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 22fd2cc

@Zachiah
Copy link
Contributor Author

Zachiah commented May 8, 2024

I somehow got some weird stuff in my last commit so I rewrote history to fix it. Hope that's alright 😄

@baldwindavid
Copy link
Contributor

baldwindavid commented May 8, 2024

@Zachiah Thanks for working on this! I pulled the branch down and tested a bit. A few notes:


I set a mark with ma, moved to another part of the file, and then typed 'a. While the cursor position did jump to that marked location, the viewport did not. I had to move the cursor for the viewport's position to update.


vim: Adds limited support for the builtin ^ mark

Maybe this should be part of this functionality, but worth mentioning that the Default Vim Bindings file already makes this work with...

"^": "vim::FirstNonWhitespace",

Add uppercase marks

The lowercase marks will be very useful on their own. Will be good to get the maintainers' take on this; if I were to guess they may want to leverage some sort of global bookmark functionality that is not just vim specific. It would be neat for uppercase marks to display bookmarks in the gutter like requested in #4526 and for them to survive application restarts.

@Zachiah
Copy link
Contributor Author

Zachiah commented May 8, 2024

@baldwindavid I will take a look. In regards to the ^ mark that is unrelated to the ^ motion. The ^ mark (as in '^ or `^ takes you to the place you were when you last exited insert mode. I also misspoke in my earlier comment. The ^ mark works fine it is the < and > marks that aren't fully implemented. I was working with @ConradIrwin and we decided not to make them work with visual block mode because there are some strange edge cases and it is only an initial implementation.

On a separate note, I discovered a bug with the multi-cursor mark implementation I have currently. I was aiming to make the marks work with multi-cursor, but right now if you do a multi-cursor selection and set a mark then try to return to the mark it will crash the entire editor with a panic. I'll either fix the issue or just remove multi-cursor marks for now

Regarding uppercase marks, should I hold up on implementing those until we have more consensus on how they should work?

@ConradIrwin
Copy link
Collaborator

I think we should probably merge this (once the panic is fixed) and do uppercase marks as a follow up.

We may be able to do a simple version of uppercase marks that doesn't have persistence (as that way we can just store the buffer id and anchor in RAM), and when you close the buffer the mark stops working.

If we want persistence, I think we need to serialize them to sqlite as file + line + column, and convert back to an anchor whenever a buffer containing that file is opened.

@baldwindavid
Copy link
Contributor

We may be able to do a simple version of uppercase marks that doesn't have persistence (as that way we can just store the buffer id and anchor in RAM), and when you close the buffer the mark stops working.

👍 Who knows how devs use this, but I suspect this covers 95% of usage.

}
ranges.insert(anchor..anchor);
}
editor.change_selections(None, cx, |s| s.select_anchor_ranges(ranges))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zachiah to fix the scrolling issue, this None needs to be Some(AutoScroll::fit())

@Zachiah
Copy link
Contributor Author

Zachiah commented May 9, 2024

Some observations on the panic:

  • If I have 2 cursors it works with the ' mark but fails with the ` mark.
  • If I have 3 cursors it works a few times (usually only once) with the ' mark then fails after doing the same thing after a certain amount of times (seemingly random). It also fails on `
  • Any more than 3 cursors seems to fail every time. (I have seen it work once with 4 cursors but after trying a second time it failed)

@ConradIrwin Do you have any ideas what would cause behavior like this? It isn't very clear to me where to begin debugging.

The entire stacktrace
    Thread "main" panicked with "cannot seek backward from (Some(Locator([983025])), 15) to Some(Locator([524280]))" at /Users/zachiahsawyer/Git/zed/crates/sum_tree/src/cursor.rs:416:9
   0: backtrace::backtrace::libunwind::trace
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
      backtrace::backtrace::trace_unsynchronized::<<backtrace::capture::Backtrace>::create::{closure#0}>
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace::<<backtrace::capture::Backtrace>::create::{closure#0}>
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
   2: <backtrace::capture::Backtrace>::create
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
   3: <backtrace::capture::Backtrace>::new
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22
   4: Zed::reliability::init_panic_hook::{closure#0}
             at crates/zed/src/reliability.rs:83:29
   5: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
      std::panicking::rust_panic_with_hook
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13
   6: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:657:13
   7: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18
   8: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   9: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
  10: <sum_tree::cursor::Cursor<text::Fragment, (core::option::Option<&text::locator::Locator>, usize)>>::seek_internal
             at crates/sum_tree/src/cursor.rs:416:9
  11: <sum_tree::cursor::Cursor<text::Fragment, (core::option::Option<&text::locator::Locator>, usize)>>::seek_forward::<core::option::Option<&text::locator::Locator>>
             at crates/sum_tree/src/cursor.rs:367:9
  12: <text::BufferSnapshot>::summaries_for_anchors_with_payload::<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}
             at crates/text/src/text.rs:1933:13
  13: <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}> as core::iter::traits::iterator::Iterator>::__iterator_get_unchecked
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/adapters/map.rs:139:18
  14: <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}> as core::iter::adapters::zip::SpecTrustedRandomAccess>::try_get_unchecked
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/adapters/zip.rs:639:18
  15: core::iter::adapters::zip::try_get_unchecked::<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/adapters/zip.rs:619:14
      <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#1}> as core::iter::traits::iterator::Iterator>::__iterator_get_unchecked
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/adapters/map.rs:139:27
  16: <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#1}> as alloc::vec::in_place_collect::SpecInPlaceCollect<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#1}>>>::collect_in_place
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/vec/in_place_collect.rs:387:33
  17: <alloc::vec::Vec<usize> as alloc::vec::spec_from_iter::SpecFromIter<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#1}>>>::from_iter
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/vec/in_place_collect.rs:253:28
  18: <alloc::vec::Vec<usize> as core::iter::traits::collect::FromIterator<usize>>::from_iter::<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#1}>>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/vec/mod.rs:2894:9
  19: <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors_with_payload<usize, core::iter::adapters::map::Map<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#0}>, ()>::{closure#0}>, <text::BufferSnapshot>::summaries_for_anchors<usize, core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<&multi_buffer::anchor::Anchor>, <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>::{closure#0}>>::{closure#1}> as core::iter::traits::iterator::Iterator>::collect::<alloc::vec::Vec<usize>>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/traits/iterator.rs:2003:9
  20: <multi_buffer::MultiBufferSnapshot>::summaries_for_anchors::<usize, alloc::vec::Vec<&multi_buffer::anchor::Anchor>>
             at crates/multi_buffer/src/multi_buffer.rs:2713:20
  21: editor::selections_collection::resolve_multiple::<usize, &alloc::vec::Vec<text::selection::Selection<multi_buffer::anchor::Anchor>>>
             at crates/editor/src/selections_collection.rs:874:25
  22: <editor::selections_collection::MutableSelectionsCollection>::select_anchors
             at crates/editor/src/selections_collection.rs:558:13
  23: <editor::selections_collection::MutableSelectionsCollection>::select_anchor_ranges::<std::collections::hash::set::HashSet<core::ops::range::Range<multi_buffer::anchor::Anchor>>>
             at crates/editor/src/selections_collection.rs:627:9
  24: vim::normal::mark::jump::{closure#2}::{closure#0}::{closure#0}
             at crates/vim/src/normal/mark.rs:128:21
  25: <editor::selections_collection::SelectionsCollection>::change_with::<(), vim::normal::mark::jump::{closure#2}::{closure#0}::{closure#0}>
             at crates/editor/src/selections_collection.rs:353:22
  26: <editor::Editor>::change_selections::<(), vim::normal::mark::jump::{closure#2}::{closure#0}::{closure#0}>
             at crates/editor/src/editor.rs:2159:33
  27: vim::normal::mark::jump::{closure#2}::{closure#0}
             at crates/vim/src/normal/mark.rs:127:17
  28: <vim::Vim>::update_active_editor::<(), vim::normal::mark::jump::{closure#2}::{closure#0}>::{closure#0}
             at crates/vim/src/vim.rs:313:45
  29: <gpui::window::WindowContext as gpui::VisualContext>::update_view::<editor::Editor, (), <vim::Vim>::update_active_editor<(), vim::normal::mark::jump::{closure#2}::{closure#0}>::{closure#0}>
             at crates/gpui/src/window.rs:3585:22
  30: <gpui::view::View<editor::Editor>>::update::<gpui::window::WindowContext, (), <vim::Vim>::update_active_editor<(), vim::normal::mark::jump::{closure#2}::{closure#0}>::{closure#0}>
             at crates/gpui/src/view.rs:76:9
  31: <vim::Vim>::update_active_editor::<(), vim::normal::mark::jump::{closure#2}::{closure#0}>
             at crates/vim/src/vim.rs:313:14
  32: vim::normal::mark::jump::{closure#2}
             at crates/vim/src/normal/mark.rs:113:13
  33: <gpui::window::WindowContext as gpui::BorrowAppContext>::update_global::<vim::Vim, (), vim::normal::mark::jump::{closure#2}>
             at crates/gpui/src/gpui.rs:307:22
  34: <vim::Vim>::update::<vim::normal::mark::jump::{closure#2}, ()>
             at crates/vim/src/vim.rs:236:9
  35: vim::normal::mark::jump
             at crates/vim/src/normal/mark.rs:112:9
  36: <vim::Vim>::active_editor_input_ignored
             at crates/vim/src/vim.rs:729:46
  37: <vim::Vim>::activate_editor::{closure#0}
             at crates/vim/src/vim.rs:254:17
  38: <gpui::window::WindowContext>::subscribe::<editor::Editor, gpui::view::View<editor::Editor>, editor::EditorEvent, <vim::Vim>::activate_editor::{closure#0}>::{closure#0}::{closure#0}
             at crates/gpui/src/window.rs:1043:33
  39: <gpui::app::AppContext as gpui::Context>::update_window::<bool, <gpui::window::WindowContext>::subscribe<editor::Editor, gpui::view::View<editor::Editor>, editor::EditorEvent, <vim::Vim>::activate_editor::{closure#0}>::{closure#0}::{closure#0}>::{closure#0}
             at crates/gpui/src/app.rs:1322:26
  40: <gpui::app::AppContext>::update::<core::result::Result<bool, anyhow::Error>, <gpui::app::AppContext as gpui::Context>::update_window<bool, <gpui::window::WindowContext>::subscribe<editor::Editor, gpui::view::View<editor::Editor>, editor::EditorEvent, <vim::Vim>::activate_editor::{closure#0}>::{closure#0}::{closure#0}>::{closure#0}>
             at crates/gpui/src/app.rs:363:22
  41: <gpui::app::AppContext as gpui::Context>::update_window::<bool, <gpui::window::WindowContext>::subscribe<editor::Editor, gpui::view::View<editor::Editor>, editor::EditorEvent, <vim::Vim>::activate_editor::{closure#0}>::{closure#0}::{closure#0}>
             at crates/gpui/src/app.rs:1313:9
  42: <gpui::window::AnyWindowHandle>::update::<gpui::app::AppContext, bool, <gpui::window::WindowContext>::subscribe<editor::Editor, gpui::view::View<editor::Editor>, editor::EditorEvent, <vim::Vim>::activate_editor::{closure#0}>::{closure#0}::{closure#0}>
             at crates/gpui/src/window.rs:4417:9
  43: <gpui::window::WindowContext>::subscribe::<editor::Editor, gpui::view::View<editor::Editor>, editor::EditorEvent, <vim::Vim>::activate_editor::{closure#0}>::{closure#0}
             at crates/gpui/src/window.rs:1039:21
  44: <alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>> as core::ops::function::FnMut<(&dyn core::any::Any, &mut gpui::app::AppContext)>>::call_mut
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2027:9
  45: <gpui::app::AppContext>::apply_emit_effect::{closure#0}
             at crates/gpui/src/app.rs:794:21
  46: <gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain::<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}
             at crates/gpui/src/subscription.rs:125:17
  47: <alloc::collections::btree::map::BTreeMap<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::retain::<<gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}>::{closure#0}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/collections/btree/map.rs:1115:33
  48: <alloc::collections::btree::map::ExtractIfInner<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::next::<<alloc::collections::btree::map::BTreeMap<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::retain<<gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}>::{closure#0}, alloc::alloc::Global>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/collections/btree/map.rs:1944:16
  49: <alloc::collections::btree::map::ExtractIf<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>, <alloc::collections::btree::map::BTreeMap<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::retain<<gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}>::{closure#0}> as core::iter::traits::iterator::Iterator>::next
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/collections/btree/map.rs:1922:9
  50: <alloc::collections::btree::map::ExtractIf<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>, <alloc::collections::btree::map::BTreeMap<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::retain<<gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}>::{closure#0}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<(usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>), core::mem::drop<(usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>)>>::{closure#0}>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/traits/iterator.rs:2586:29
  51: <alloc::collections::btree::map::ExtractIf<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>, <alloc::collections::btree::map::BTreeMap<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::retain<<gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}>::{closure#0}> as core::iter::traits::iterator::Iterator>::for_each::<core::mem::drop<(usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>)>>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/iter/traits/iterator.rs:817:9
      <alloc::collections::btree::map::BTreeMap<usize, gpui::subscription::Subscriber<(core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>>::retain::<<gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>::{closure#1}>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/collections/btree/map.rs:1115:42
  52: <gpui::subscription::SubscriberSet<gpui::app::entity_map::EntityId, (core::any::TypeId, alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnMut<(&'a dyn core::any::Any, &'b mut gpui::app::AppContext), Output = bool>>)>>::retain::<<gpui::app::AppContext>::apply_emit_effect::{closure#0}>
             at crates/gpui/src/subscription.rs:123:9
  53: <gpui::app::AppContext>::apply_emit_effect
             at crates/gpui/src/app.rs:790:9
  54: <gpui::app::AppContext>::flush_effects
             at crates/gpui/src/app.rs:700:26
  55: <gpui::app::AppContext>::update::<core::result::Result<(), anyhow::Error>, <gpui::app::AppContext as gpui::Context>::update_window<(), <gpui::app::async_context::AsyncWindowContext>::update<(), <gpui::platform::PlatformInputHandler>::replace_text_in_range::{closure#0}>::{closure#0}>::{closure#0}>
             at crates/gpui/src/app.rs:366:13
  56: <gpui::app::AppContext as gpui::Context>::update_window::<(), <gpui::app::async_context::AsyncWindowContext>::update<(), <gpui::platform::PlatformInputHandler>::replace_text_in_range::{closure#0}>::{closure#0}>
             at crates/gpui/src/app.rs:1313:9
  57: <gpui::app::async_context::AsyncAppContext as gpui::Context>::update_window::<(), <gpui::app::async_context::AsyncWindowContext>::update<(), <gpui::platform::PlatformInputHandler>::replace_text_in_range::{closure#0}>::{closure#0}>
             at crates/gpui/src/app/async_context.rs:91:9
  58: <gpui::app::async_context::AsyncWindowContext>::update::<(), <gpui::platform::PlatformInputHandler>::replace_text_in_range::{closure#0}>
             at crates/gpui/src/app/async_context.rs:242:9
  59: <gpui::platform::PlatformInputHandler>::replace_text_in_range
             at crates/gpui/src/platform.rs:406:9
  60: gpui::platform::mac::window::send_to_input_handler
             at crates/gpui/src/platform/mac/window.rs:1944:21
  61: gpui::platform::mac::window::handle_key_event
             at crates/gpui/src/platform/mac/window.rs:1273:17
  62: gpui::platform::mac::window::handle_key_down
             at crates/gpui/src/platform/mac/window.rs:1187:5
  63: <unknown>
  64: <unknown>
  65: <unknown>
  66: <unknown>
  67: <unknown>
  68: <() as objc::message::MessageArguments>::invoke::<()>
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:128:17
  69: objc::message::platform::send_unverified::<objc::runtime::Object, (), ()>
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:27:9
  70: objc::message::send_message::<objc::runtime::Object, (), ()>
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:178:5
      <*mut objc::runtime::Object as cocoa::appkit::NSApplication>::run
             at /Users/zachiahsawyer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cocoa-0.25.0/src/appkit.rs:603:9
  71: <gpui::platform::mac::platform::MacPlatform as gpui::platform::Platform>::run
             at crates/gpui/src/platform/mac/platform.rs:371:13
  72: <gpui::app::App>::run::<Zed::init_ui::{closure#3}>
             at crates/gpui/src/app.rs:142:9
  73: Zed::init_ui
             at crates/zed/src/main.rs:233:5
  74: Zed::main
             at crates/zed/src/main.rs:445:9
  75: <fn() as core::ops::function::FnOnce<()>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
  76: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:155:18
  77: std::rt::lang_start::<()>::{closure#0}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:166:18
  78: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
      std::rt::lang_start_internal
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:148:20
  79: std::rt::lang_start::<()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:165:17
  80: _main

@ConradIrwin
Copy link
Collaborator

Looks like the select_ranges requires that the anchors are ordered correctly. I've updated our de-duping logic to not use a HashSet which seems to fix it.

@ConradIrwin ConradIrwin merged commit 901cb8b into zed-industries:main May 10, 2024
12 checks passed
osiewicz pushed a commit to RemcoSmitsDev/zed that referenced this pull request May 18, 2024
Release Notes:
- vim: Added support for buffer-local marks (`'a-'z`) and some builtin
marks `'<`,`'>`,`'[`,`']`, `'{`, `'}` and `^`. Global marks (`'A-'Z`),
and other builtin marks (`'0-'9`, `'(`, `')`, `''`, `'.`, `'"`) are not
yet implemented. (zed-industries#5122)

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
@baldwindavid baldwindavid mentioned this pull request Jun 16, 2024
1 task
@Moshyfawn Moshyfawn mentioned this pull request Jun 16, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants