Ensure Perl comments are treated as atoms with an atom kind of comment

pull/281/head
Wilfred Hughes 2022-04-29 18:23:31 +07:00
parent 75a3624f7c
commit 3bb5933163
5 changed files with 8 additions and 5 deletions

@ -5,6 +5,8 @@
Improved detection of binary files that have a large number of null
bytes.
Improved handling of comments in Perl.
## 0.28 (released 29th April 2022)
### Parsing

@ -110,7 +110,7 @@ sample_files/outer_delimiter_before.el sample_files/outer_delimiter_after.el
73130b8572a4f17fa6cf828f74e226ce -
sample_files/perl_before.pl sample_files/perl_after.pl
0067b33629bd714177294d913f59f1b4 -
08d7cad58a79d423c0584387d4bb4dd1 -
sample_files/preprocesor_before.h sample_files/preprocesor_after.h
3e4331cb935cbe735a79ebc43786cd3a -

@ -9,7 +9,7 @@ use constant DEBUG , 0; # comma (,) is also used instead of '=>'
print "Pi equals ", PI, "...\n";
use constant {
SEC => 0,
SEC => 0, # foo
MIN => 1,
HOUR => 2,
MDAY => 3,

@ -9,7 +9,7 @@ use constant DEBUG , 0; # comma (,) is also used instead of '=>'
print "Pi equals ", PI, "...\n";
use constant {
SEC => 0,
SEC => 0, # foo bar
MIN => 1,
HOUR => 2,
MDAY => 3,

@ -502,7 +502,7 @@ pub fn from_language(language: guess::Language) -> TreeSitterConfig {
TreeSitterConfig {
name: "Perl",
language,
atom_nodes: vec!["string_single_quoted", "string_double_quoted"]
atom_nodes: vec!["string_single_quoted", "string_double_quoted", "comments"]
.into_iter()
.collect(),
delimiter_tokens: vec![("(", ")"), ("{", "}"), ("[", "]")],
@ -1092,7 +1092,8 @@ fn atom_from_cursor<'a>(
content = content.trim();
}
let highlight = if node.is_extra() || node.kind() == "comment" {
// Most languages use "comment", but Perl uses "comments".
let highlight = if node.is_extra() || node.kind() == "comment" || node.kind() == "comments" {
AtomKind::Comment
} else if highlights.keyword_ids.contains(&node.id()) {
AtomKind::Keyword