From cd65a48635d49ccc2aed55a315c3a33875e13f88 Mon Sep 17 00:00:00 2001 From: Cor Peters Date: Sun, 18 Jul 2021 18:33:38 +0200 Subject: Made toggle_comments language dependent (#463) * Made toggle_comments language dependent * Fixed Test Cases * Added clippy suggestion * Small Fixes * Clippy Suggestion Co-authored-by: Cor --- helix-term/src/commands.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7e769f4e..5fc96cd9 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3399,7 +3399,11 @@ fn hover(cx: &mut Context) { // comments fn toggle_comments(cx: &mut Context) { let (view, doc) = current!(cx.editor); - let transaction = comment::toggle_line_comments(doc.text(), doc.selection(view.id)); + let token = doc + .language_config() + .and_then(|lc| lc.comment_token.as_ref()) + .map(|tc| tc.as_ref()); + let transaction = comment::toggle_line_comments(doc.text(), doc.selection(view.id), token); doc.apply(&transaction, view.id); doc.append_changes_to_history(view.id); -- cgit v1.2.3-70-g09d2