Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Add Toggle Comment support for several more languages #3056

Closed
wants to merge 1 commit into from

Conversation

peterflynn
Copy link
Member

Toggle Line and/or Block Comment support for: Java, CoffeeScript, Perl, Ruby, Python, SASS, Lua, Markdown, YAML, Haxe. All these languages were included in core already.

I hit a few snags while working on this:

  • CoffeeScript supports block comments via ###, but Toggle Block Comment behaves badly (I think because the open/close delimiters are identical). So I've only included lineComment for now. Filed Toggle Block Comment doesn't work if the open/close delimiters are the same #3057 on this.
  • I wasn't clear on whether Ruby officially supports block comments. I've seen mention of =begin and =end but couldn't find any real-world code that uses this (and I'm not clear what the "rules" are -- e.g. do those delimiters have to be alone on a line?). So I only included lineComment for now.
  • Clojure supposedly supports line comments, but people seem to use ; and ;; equally. We'd probably want uncomment to fully strip either flavor, which we don't support yet. But Clojure being functional, toggling line comments also seems very rare -- toggling block comments might be useful, except it seems Clojure doesn't offer block comments. So I've left Clojure out for now.

…n core

already): Java, CoffeeScript, Perl, Ruby, Python, SASS, Lua, Markdown, YAML,
Haxe.
@ghost ghost assigned TomMalbran Mar 8, 2013
@TomMalbran
Copy link
Contributor

@peterflynn Want me to review this now or after #3057 is fixed, so that you can add block comments for CoffeScript?

@TomMalbran
Copy link
Contributor

@peterflynn I tested the commenting for each new language and it doesn't quite work with Lua.

Block uncomment will just remove the first "--" if those are at the start of the string (without considering spaces). The problem is for the same reason line and block comments for CoffeScript don't work, the line comment is the prefix of the block comment prefix.

There is also another problem. Line uncomment on a block comment that covers the entire line will just remove the first "--" leaving an invalid string. The same thing will happen in CoffeScript. This is not as bad, but maybe line comment should check with the block prefix too and do nothing if it finds it at the start of any line, or at least go to comment mode, instead of uncomment.

@miketheman
Copy link

@TomMalbran This has been open for a while, and looks like there have been multiple PRs/Commits since then for individual languages - but not all of the ones specified here.

@peterflynn Any chance you'd make a pass at closing these out by providing the differentials?

Thanks!

@TomMalbran
Copy link
Contributor

@miketheman There is a bug for Lua block/line comments, since the line ones are prefix of the block ones. This should have been fixed by #3057, but was never merged. Feel free to make a new PR for all the other languages except Lua.

@TomMalbran
Copy link
Contributor

I guess I could also fix that in this one and merge it

@miketheman
Copy link

@TomMalbran I was looking for yaml today, hence the ping on this issue. :)

@ahuth
Copy link

ahuth commented Feb 6, 2014

@peterflynn The rules for ruby's block comments are:

  • the =begin and =end have to be on their own lines
  • the =begin and =end have to be at the beginning of their respective line (no spaces or tabs)

As you observed, though, these are almost never used. It's probably safe to leave them out.

@TomMalbran
Copy link
Contributor

Wasn't able to merge with master because of some issues with the submodules, so I did a manual merge: 3a12c21. (I hope that is ok)

I haven't added the comments for CoffeeScript and Lua, since those don't work well yet. But I will add them when I redo the comments fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants