From bdd953e5b191db0ddc0bcde1468d394706a20481 Mon Sep 17 00:00:00 2001 From: Nik Revenco Date: Tue, 17 Jun 2025 15:01:33 +0100 Subject: [PATCH] chore: Use `&[T]` instead of `&Vec` Co-authored-by: Michael Davis --- helix-core/src/comment.rs | 14 +++++++------- helix-term/src/commands.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs index 5e5c58f8b..e8a855611 100644 --- a/helix-core/src/comment.rs +++ b/helix-core/src/comment.rs @@ -17,7 +17,7 @@ pub fn get_line_comment_token( loader: &syntax::Loader, syntax: Option<&Syntax>, text: RopeSlice, - doc_default_tokens: Option<&Vec>, + doc_default_tokens: Option<&[String]>, line_num: usize, ) -> Option { let line = text.line(line_num); @@ -210,7 +210,7 @@ pub enum CommentChange { pub fn find_block_comments( tokens: &[BlockCommentToken], text: RopeSlice, - ranges: &Vec, + ranges: &[Range], ) -> (bool, Vec) { let mut was_commented = true; let mut only_whitespace = true; @@ -361,7 +361,7 @@ pub fn create_block_comment_transaction( #[must_use] pub fn toggle_block_comments( doc: &Rope, - ranges: &Vec, + ranges: &[Range], tokens: &[BlockCommentToken], selections: &mut SmallVec<[Range; 1]>, added_chars: &mut usize, @@ -542,7 +542,7 @@ mod test { let text = doc.slice(..); - let res = find_block_comments(&[BlockCommentToken::default()], text, &vec![range]); + let res = find_block_comments(&[BlockCommentToken::default()], text, &[range]); assert_eq!( res, @@ -561,7 +561,7 @@ mod test { // comment let changes = toggle_block_comments( &doc, - &vec![range], + &[range], &[BlockCommentToken::default()], &mut SmallVec::new(), &mut 0, @@ -576,7 +576,7 @@ mod test { let range = Range::new(0, doc.len_chars()); let changes = toggle_block_comments( &doc, - &vec![range], + &[range], &[BlockCommentToken::default()], &mut SmallVec::new(), &mut 0, @@ -591,7 +591,7 @@ mod test { let range = Range::new(0, doc.len_chars()); let changes = toggle_block_comments( &doc, - &vec![range], + &[range], &[BlockCommentToken::default()], &mut SmallVec::new(), &mut 0, diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index bdb7618d8..6ccbde19e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3654,7 +3654,7 @@ fn open(cx: &mut Context, open: Open, comment_continuation: CommentContinuation) let doc_default_tokens = doc .language_config() - .and_then(|config| config.comment_tokens.as_ref()); + .and_then(|config| config.comment_tokens.as_deref()); let syntax = doc.syntax(); @@ -4214,7 +4214,7 @@ pub mod insert { let doc_default_comment_token = doc .language_config() - .and_then(|config| config.comment_tokens.as_ref()); + .and_then(|config| config.comment_tokens.as_deref()); let syntax = doc.syntax(); @@ -5272,7 +5272,7 @@ fn toggle_comments(cx: &mut Context) { let (block_commented, comment_changes) = comment::find_block_comments( block_comment_tokens, rope.slice(..), - &vec![*range], + &[*range], ); if block_commented {