mirror of https://github.com/helix-editor/helix
chore: Use `&[T]` instead of `&Vec<T>`
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>pull/12759/head
parent
6e52d9439f
commit
bdd953e5b1
|
@ -17,7 +17,7 @@ pub fn get_line_comment_token(
|
||||||
loader: &syntax::Loader,
|
loader: &syntax::Loader,
|
||||||
syntax: Option<&Syntax>,
|
syntax: Option<&Syntax>,
|
||||||
text: RopeSlice,
|
text: RopeSlice,
|
||||||
doc_default_tokens: Option<&Vec<String>>,
|
doc_default_tokens: Option<&[String]>,
|
||||||
line_num: usize,
|
line_num: usize,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let line = text.line(line_num);
|
let line = text.line(line_num);
|
||||||
|
@ -210,7 +210,7 @@ pub enum CommentChange {
|
||||||
pub fn find_block_comments(
|
pub fn find_block_comments(
|
||||||
tokens: &[BlockCommentToken],
|
tokens: &[BlockCommentToken],
|
||||||
text: RopeSlice,
|
text: RopeSlice,
|
||||||
ranges: &Vec<Range>,
|
ranges: &[Range],
|
||||||
) -> (bool, Vec<CommentChange>) {
|
) -> (bool, Vec<CommentChange>) {
|
||||||
let mut was_commented = true;
|
let mut was_commented = true;
|
||||||
let mut only_whitespace = true;
|
let mut only_whitespace = true;
|
||||||
|
@ -361,7 +361,7 @@ pub fn create_block_comment_transaction(
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn toggle_block_comments(
|
pub fn toggle_block_comments(
|
||||||
doc: &Rope,
|
doc: &Rope,
|
||||||
ranges: &Vec<Range>,
|
ranges: &[Range],
|
||||||
tokens: &[BlockCommentToken],
|
tokens: &[BlockCommentToken],
|
||||||
selections: &mut SmallVec<[Range; 1]>,
|
selections: &mut SmallVec<[Range; 1]>,
|
||||||
added_chars: &mut usize,
|
added_chars: &mut usize,
|
||||||
|
@ -542,7 +542,7 @@ mod test {
|
||||||
|
|
||||||
let text = doc.slice(..);
|
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!(
|
assert_eq!(
|
||||||
res,
|
res,
|
||||||
|
@ -561,7 +561,7 @@ mod test {
|
||||||
// comment
|
// comment
|
||||||
let changes = toggle_block_comments(
|
let changes = toggle_block_comments(
|
||||||
&doc,
|
&doc,
|
||||||
&vec![range],
|
&[range],
|
||||||
&[BlockCommentToken::default()],
|
&[BlockCommentToken::default()],
|
||||||
&mut SmallVec::new(),
|
&mut SmallVec::new(),
|
||||||
&mut 0,
|
&mut 0,
|
||||||
|
@ -576,7 +576,7 @@ mod test {
|
||||||
let range = Range::new(0, doc.len_chars());
|
let range = Range::new(0, doc.len_chars());
|
||||||
let changes = toggle_block_comments(
|
let changes = toggle_block_comments(
|
||||||
&doc,
|
&doc,
|
||||||
&vec![range],
|
&[range],
|
||||||
&[BlockCommentToken::default()],
|
&[BlockCommentToken::default()],
|
||||||
&mut SmallVec::new(),
|
&mut SmallVec::new(),
|
||||||
&mut 0,
|
&mut 0,
|
||||||
|
@ -591,7 +591,7 @@ mod test {
|
||||||
let range = Range::new(0, doc.len_chars());
|
let range = Range::new(0, doc.len_chars());
|
||||||
let changes = toggle_block_comments(
|
let changes = toggle_block_comments(
|
||||||
&doc,
|
&doc,
|
||||||
&vec![range],
|
&[range],
|
||||||
&[BlockCommentToken::default()],
|
&[BlockCommentToken::default()],
|
||||||
&mut SmallVec::new(),
|
&mut SmallVec::new(),
|
||||||
&mut 0,
|
&mut 0,
|
||||||
|
|
|
@ -3654,7 +3654,7 @@ fn open(cx: &mut Context, open: Open, comment_continuation: CommentContinuation)
|
||||||
|
|
||||||
let doc_default_tokens = doc
|
let doc_default_tokens = doc
|
||||||
.language_config()
|
.language_config()
|
||||||
.and_then(|config| config.comment_tokens.as_ref());
|
.and_then(|config| config.comment_tokens.as_deref());
|
||||||
|
|
||||||
let syntax = doc.syntax();
|
let syntax = doc.syntax();
|
||||||
|
|
||||||
|
@ -4214,7 +4214,7 @@ pub mod insert {
|
||||||
|
|
||||||
let doc_default_comment_token = doc
|
let doc_default_comment_token = doc
|
||||||
.language_config()
|
.language_config()
|
||||||
.and_then(|config| config.comment_tokens.as_ref());
|
.and_then(|config| config.comment_tokens.as_deref());
|
||||||
|
|
||||||
let syntax = doc.syntax();
|
let syntax = doc.syntax();
|
||||||
|
|
||||||
|
@ -5272,7 +5272,7 @@ fn toggle_comments(cx: &mut Context) {
|
||||||
let (block_commented, comment_changes) = comment::find_block_comments(
|
let (block_commented, comment_changes) = comment::find_block_comments(
|
||||||
block_comment_tokens,
|
block_comment_tokens,
|
||||||
rope.slice(..),
|
rope.slice(..),
|
||||||
&vec![*range],
|
&[*range],
|
||||||
);
|
);
|
||||||
|
|
||||||
if block_commented {
|
if block_commented {
|
||||||
|
|
Loading…
Reference in New Issue