Skip to content

Commit

Permalink
highlight # ... as comment at end of line in syn_generic
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Nov 3, 2024
1 parent b85098f commit dc1e905
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ static void _editor_init_syntaxes(editor_t *editor) {
{ "`([^`\\\\]|\\\\.)*`", NULL, TB_YELLOW | TB_BOLD, TB_DEFAULT },
{ "/\\*", "\\*/", TB_CYAN, TB_DEFAULT },
{ "//.*$", NULL, TB_CYAN, TB_DEFAULT },
{ "^\\s*#( .*|)$", NULL, TB_CYAN, TB_DEFAULT },
{ "(?<=\\s)#\\s.*$", NULL, TB_CYAN, TB_DEFAULT },
{ "^#!/.*$", NULL, TB_CYAN, TB_DEFAULT },
{ "[(){}<>\\[\\].,;:?!+=/\\\\%^*-]", NULL, TB_RED | TB_BOLD, TB_DEFAULT },
{ "(?<!\\w)[\\%@$][a-zA-Z_$][a-zA-Z0-9_]*\\b", NULL, TB_GREEN, TB_DEFAULT },
Expand Down
17 changes: 17 additions & 0 deletions tests/func/test_syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,20 @@ expected[style_sc_b]='<ch=98 fg=7\b'
not_expected[style_sc_not_a]='<ch=97 fg=(0|7)\b'
not_expected[style_sc_not_b]='<ch=98 fg=(0|260)\b'
source 'test.sh'

cat >$tmpf <<"EOD"
aaa "bbb" // ccc "ccc"
aaa "bbb" # ccc "ccc"
EOD
extra_opts=(-yy $tmpf)
macro=''
declare -A expected
declare -A not_expected
# a==97 b==98 c==99
expected[style_a]='<ch=97 fg=0\b'
expected[style_b]='<ch=98 fg=260\b'
expected[style_c]='<ch=99 fg=7\b'
not_expected[style_not_a]='<ch=97 fg=(260|7)\b'
not_expected[style_not_b]='<ch=98 fg=(0|7)\b'
not_expected[style_not_c]='<ch=99 fg=(0|260)\b'
source 'test.sh'

0 comments on commit dc1e905

Please sign in to comment.