diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cc13654e9e3f42a1abc49d983aa764d5acdf7436..12d77de0c20fd1b3b3939cc7564e99a2e6e9b265 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -10522,7 +10522,7 @@ impl Editor { for selection in self .selections - .all::(&self.display_snapshot(cx)) + .all_adjusted(&self.display_snapshot(cx)) .iter() { let Some(wrap_config) = snapshot diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 93b610877a163ba0f3035e8a0483f531a3246e6c..cb02a3ab0fafdeec254e8b3722bdd877fbeda0e2 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -2,19 +2,21 @@ mod neovim_backed_test_context; mod neovim_connection; mod vim_test_context; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; use collections::HashMap; use command_palette::CommandPalette; use editor::{ - AnchorRangeExt, DisplayPoint, Editor, EditorMode, MultiBuffer, actions::DeleteLine, - code_context_menus::CodeContextMenu, display_map::DisplayRow, + AnchorRangeExt, DisplayPoint, Editor, EditorMode, MultiBuffer, + actions::{DeleteLine, WrapSelectionsInTag}, + code_context_menus::CodeContextMenu, + display_map::DisplayRow, test::editor_test_context::EditorTestContext, }; use futures::StreamExt; use gpui::{KeyBinding, Modifiers, MouseButton, TestAppContext, px}; use itertools::Itertools; -use language::Point; +use language::{Language, LanguageConfig, Point}; pub use neovim_backed_test_context::*; use settings::SettingsStore; use ui::Pixels; @@ -2319,3 +2321,47 @@ async fn test_clipping_on_mode_change(cx: &mut gpui::TestAppContext) { Mode::Normal, ); } + +#[gpui::test] +async fn test_wrap_selections_in_tag_line_mode(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + let js_language = Arc::new(Language::new( + LanguageConfig { + name: "JavaScript".into(), + wrap_characters: Some(language::WrapCharactersConfig { + start_prefix: "<".into(), + start_suffix: ">".into(), + end_prefix: "".into(), + }), + ..LanguageConfig::default() + }, + None, + )); + + cx.update_buffer(|buffer, cx| buffer.set_language(Some(js_language), cx)); + + cx.set_state( + indoc! { + " + ˇaaaaa + bbbbb + " + }, + Mode::Normal, + ); + + cx.simulate_keystrokes("shift-v j"); + cx.dispatch_action(WrapSelectionsInTag); + + cx.assert_state( + indoc! { + " + <ˇ>aaaaa + bbbbb + " + }, + Mode::VisualLine, + ); +}