mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-24 10:26:18 +04:00
Merge e7e538c2b4
into b8313da5a8
This commit is contained in:
commit
0d6671dcfd
@ -9,7 +9,7 @@
|
|||||||
use helix_stdx::rope::RopeSliceExt;
|
use helix_stdx::rope::RopeSliceExt;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
pub const DEFAULT_COMMENT_TOKEN: &str = "//";
|
pub const DEFAULT_COMMENT_TOKEN: &str = "#";
|
||||||
|
|
||||||
/// Returns the longest matching comment token of the given line (if it exists).
|
/// Returns the longest matching comment token of the given line (if it exists).
|
||||||
pub fn get_comment_token<'a, S: AsRef<str>>(
|
pub fn get_comment_token<'a, S: AsRef<str>>(
|
||||||
@ -345,7 +345,7 @@ fn not_commented() {
|
|||||||
|
|
||||||
let text = doc.slice(..);
|
let text = doc.slice(..);
|
||||||
|
|
||||||
let res = find_line_comment("//", text, 0..3);
|
let res = find_line_comment("#", text, 0..3);
|
||||||
// (commented = false, to_change = [line 0, line 2], min = col 2, margin = 0)
|
// (commented = false, to_change = [line 0, line 2], min = col 2, margin = 0)
|
||||||
assert_eq!(res, (false, vec![0, 2], 2, 0));
|
assert_eq!(res, (false, vec![0, 2], 2, 0));
|
||||||
}
|
}
|
||||||
@ -353,9 +353,9 @@ fn not_commented() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn is_commented() {
|
fn is_commented() {
|
||||||
// three lines where the second line is empty.
|
// three lines where the second line is empty.
|
||||||
let doc = Rope::from("// hello\n\n// there");
|
let doc = Rope::from("# hello\n\n# there");
|
||||||
|
|
||||||
let res = find_line_comment("//", doc.slice(..), 0..3);
|
let res = find_line_comment("#", doc.slice(..), 0..3);
|
||||||
|
|
||||||
// (commented = true, to_change = [line 0, line 2], min = col 0, margin = 1)
|
// (commented = true, to_change = [line 0, line 2], min = col 0, margin = 1)
|
||||||
assert_eq!(res, (true, vec![0, 2], 0, 1));
|
assert_eq!(res, (true, vec![0, 2], 0, 1));
|
||||||
@ -376,12 +376,12 @@ fn comment() {
|
|||||||
let transaction = toggle_line_comments(&doc, &selection, None);
|
let transaction = toggle_line_comments(&doc, &selection, None);
|
||||||
transaction.apply(&mut doc);
|
transaction.apply(&mut doc);
|
||||||
|
|
||||||
assert_eq!(doc, " // 1\n\n // 2\n // 3");
|
assert_eq!(doc, " # 1\n\n # 2\n # 3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uncomment() {
|
fn uncomment() {
|
||||||
let mut doc = Rope::from(" // 1\n\n // 2\n // 3");
|
let mut doc = Rope::from(" # 1\n\n # 2\n # 3");
|
||||||
let mut selection = Selection::single(0, doc.len_chars() - 1);
|
let mut selection = Selection::single(0, doc.len_chars() - 1);
|
||||||
|
|
||||||
let transaction = toggle_line_comments(&doc, &selection, None);
|
let transaction = toggle_line_comments(&doc, &selection, None);
|
||||||
@ -394,7 +394,7 @@ fn uncomment() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uncomment_0_margin_comments() {
|
fn uncomment_0_margin_comments() {
|
||||||
let mut doc = Rope::from(" //1\n\n //2\n //3");
|
let mut doc = Rope::from(" #1\n\n #2\n #3");
|
||||||
let mut selection = Selection::single(0, doc.len_chars() - 1);
|
let mut selection = Selection::single(0, doc.len_chars() - 1);
|
||||||
|
|
||||||
let transaction = toggle_line_comments(&doc, &selection, None);
|
let transaction = toggle_line_comments(&doc, &selection, None);
|
||||||
@ -407,7 +407,7 @@ fn uncomment_0_margin_comments() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uncomment_0_margin_comments_with_no_space() {
|
fn uncomment_0_margin_comments_with_no_space() {
|
||||||
let mut doc = Rope::from("//");
|
let mut doc = Rope::from("#");
|
||||||
let mut selection = Selection::single(0, doc.len_chars() - 1);
|
let mut selection = Selection::single(0, doc.len_chars() - 1);
|
||||||
|
|
||||||
let transaction = toggle_line_comments(&doc, &selection, None);
|
let transaction = toggle_line_comments(&doc, &selection, None);
|
||||||
|
Loading…
Reference in New Issue
Block a user