Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Continue multiline comments with `o` (#63751)
Ibrahim Khan52af3dd60ca8
diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rsindex e07cd34e924..b5fe19682b7 100644--- a/crates/multi_buffer/src/multi_buffer.rs+++ b/crates/multi_buffer/src/multi_buffer.rs@@ -4532,8 +4532,15 @@ impl MultiBufferSnapshot {if self.language_settings(cx).extend_comment_on_newline&& let Some(language_scope) = self.language_scope_at(Point::new(row.0, 0)){- let delimiters = language_scope.line_comment_prefixes();- for delimiter in delimiters {+ let documentation_delimiter = language_scope+ .documentation_comment()+ .filter(|_| language_scope.override_name() == Some("comment"))+ .map(|comment| &comment.prefix);+ for delimiter in language_scope+ .line_comment_prefixes()+ .iter()+ .chain(documentation_delimiter)+ {if *self.chars_at(Point::new(row.0, indent.len() as u32)).take(delimiter.chars().count())diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rsindex 7cb89a00539..113d4e20a52 100644--- a/crates/vim/src/normal.rs+++ b/crates/vim/src/normal.rs@@ -2174,6 +2174,10 @@ mod test {cx.shared_state().await.assert_eq("// hello\n// ˇ\n");cx.simulate_shared_keystrokes("x escape shift-o").await;cx.shared_state().await.assert_eq("// hello\n// ˇ\n// x\n");++ cx.set_state("/*\n * helloˇ\n */\n", Mode::Normal);+ cx.simulate_keystrokes("o");+ cx.assert_state("/*\n * hello\n * ˇ\n */\n", Mode::Insert);}#[gpui::test]