Open mattly opened 7 years ago
Additionally, could you make such comments collapsible, please. I know that for other languages, Atom doesn't make all inline comments collapsible; but for some of them it does. For example, following comment is collapsible in PHP:
/* any multiline
comment with code right after*/ $v= 1;
I took a quick look into this, but I am far from an expert on the subject of atom languages. But atom uses Tree-sitter
to parse the content of the file. It parses line by line and not with multi-line support (this is an underlying assumption that is important to my argument). It relies on regex
to match the opening and closing of multi-line comments (and other parameters). Other block commented languages often have a unique opening and closing statement such as /*
and */
make it easier to find the closing statement. The reader macro is only closed by a paren.
Consider the following simple function:
(defn func1
[args]
(clojure.string/join " " (map func2 args)))
We could implement the reader macro (#_()
) in a number of different places which would need to select different closing parens. I'll indicate where the comment should stop with the |
character.
#_(defn func1
[args]
(clojure.string/join " " (map func2 args)))|
(defn func1
[args]
#_(clojure.string/join " " (map func2 args))|)
(defn func1
[args]
(clojure.string/join " " #_(map func2 args)|))
There are regex ways (using recursion) to find the opening and closing matching parens, but given that tree-sitter doesn't have knowledge of the previous lines this becomes challening to identify the right closing paren using just the built in regex tree-sitter formatting.
Needless, I've given up modifying the simple grammar/clojure.cson
@eskemojoe007 mostly right; but Tree-sitter does work across multiple lines.
The grammar you were looking at was a TextMate grammar. Clojure does not have a Tree sitter grammar in Atom yet though, so your argument doesn’t change.
Description
From the Clojure reader reference
grammar guides for other editors will highlight the affected forms as comments.
Steps to Reproduce
#_
in front of any form, with any amount of whitespace preceding itExpected behavior: The following form should be interpreted as a comment
Actual behavior: The following form is not interpreted as a comment
Reproduces how often: always
Versions
This has happened on every version of Atom I've used, including 1.19.0