-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made toggle_comments language dependent #463
Made toggle_comments language dependent #463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This was definitely needed, just a few small comments.
By the way, thanks for all these contributions! Feel free to join us over at the Matrix Space (make sure to join #helix-editor:matrix.org
if you're on a client that doesn't support Matrix Spaces yet) -- it's where we have discussions with other developers :)
helix-view/src/document.rs
Outdated
@@ -89,7 +89,7 @@ pub struct Document { | |||
|
|||
syntax: Option<Syntax>, | |||
// /// Corresponding language scope name. Usually `source.<lang>`. | |||
pub(crate) language: Option<Arc<LanguageConfiguration>>, | |||
pub language: Option<Arc<LanguageConfiguration>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't expose this, call doc.language_config()
instead. We want to avoid being able to directly mutate most of the doc fields since there's more invariants.
helix-core/src/comment.rs
Outdated
pub fn toggle_line_comments( | ||
doc: &Rope, | ||
selection: &Selection, | ||
token: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Make this Option<&str>
, then you can token.unwrap_or("//")
without requiring that to_owned
.
helix-term/src/commands.rs
Outdated
@@ -3399,7 +3399,8 @@ 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.as_ref().and_then(|l| l.comment_token.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the Option
bound on the toggle_line_comments
you should now be able to take a reference here without cloning.
Looks like there are some conflicts, can you rebase? |
This adds a line in the language.toml file declaring the type of single line comment to use for the specified language. This still does not support comment types like xml, nor multiline comments.