Skip to content

Commit

Permalink
feat: add warning on subject overflow
Browse files Browse the repository at this point in the history
Ref: #46
  • Loading branch information
gbprod committed Jan 18, 2024
1 parent e8d9eda commit 6a693cc
Show file tree
Hide file tree
Showing 8 changed files with 34,573 additions and 34,364 deletions.
9 changes: 5 additions & 4 deletions corpus/subject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ this is a simple subject with an awesome overflow because it's longer than 50 ch

(source
(subject
(overflow)))
(overflow
(warning))))

================================================================================
Not a comment
Expand All @@ -92,8 +93,8 @@ This should not exists
--------------------------------------------------------------------------------

(source
(subject)
(ERROR))
(subject)
(ERROR))

================================================================================
Subject with type and scope
Expand Down Expand Up @@ -157,7 +158,7 @@ feat(issue42): allow numbers in scope

(source
(subject))

================================================================================
Parse fixup!
================================================================================
Expand Down
5 changes: 4 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const NEWLINE = /\r?\n/;
const ANYTHING = /[^\n\r]+/;
const SUBJECT = /[^\n\r]{1,49}/;
const OVERFLOW = /[^\n\r]{1,22}/;
const NOT_A_COMMENT = /[^#]/;
const SCISSORS = /# -+ >8 -+\r?\n/;
const BRANCH_NAME = /[^\s'”»"“]+/;
Expand Down Expand Up @@ -41,9 +42,11 @@ module.exports = grammar({
seq(NOT_A_COMMENT, SUBJECT),
seq($.prefix, $._conventional_subject)
),
optional(alias(ANYTHING, $.overflow))
optional($.overflow)
),

overflow: ($) => seq(OVERFLOW, optional(alias(ANYTHING, $.warning))),

prefix: ($) =>
seq(
alias($._conventional_type, $.type),
Expand Down
2 changes: 1 addition & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

(subject) @text.title
(subject (overflow) @text)
(subject (overflow (warning) @text.warning))
(prefix (type) @keyword)
(prefix (scope) @parameter)
(prefix [
Expand All @@ -31,4 +32,3 @@
(scissor) @comment
(subject_prefix) @keyword

(ERROR) @error
23 changes: 22 additions & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "overflow"
},
{
"type": "BLANK"
}
]
}
]
},
"overflow": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[^\\n\\r]{1,22}"
},
{
"type": "CHOICE",
"members": [
Expand All @@ -178,7 +199,7 @@
"value": "[^\\n\\r]+"
},
"named": true,
"value": "overflow"
"value": "warning"
},
{
"type": "BLANK"
Expand Down
23 changes: 19 additions & 4 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@
"named": true,
"fields": {}
},
{
"type": "overflow",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "warning",
"named": true
}
]
}
},
{
"type": "prefix",
"named": true,
Expand Down Expand Up @@ -988,10 +1003,6 @@
"type": "ny fil:",
"named": false
},
{
"type": "overflow",
"named": true
},
{
"type": "pick",
"named": false
Expand Down Expand Up @@ -1124,6 +1135,10 @@
"type": "value",
"named": true
},
{
"type": "warning",
"named": true
},
{
"type": "yeni dosya:",
"named": false
Expand Down
Loading

0 comments on commit 6a693cc

Please sign in to comment.