Skip to content

Commit

Permalink
feature: improve highlighting for dot and comma (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
levivilet authored Jan 15, 2024
1 parent 651de81 commit 3449d54
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tokenizeElm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const RE_LINE_COMMENT = /^\-\-[^\n]*/
const RE_BLOCK_COMMENT_START = /^\{\-/
const RE_BLOCK_COMMENT_END = /^\-\}/
const RE_BLOCK_COMMENT_CONTENT = /^.+(?=\-\})/s
const RE_PUNCTUATION = /^(?:\(|\)|\[|\]|\||\->)/
const RE_PUNCTUATION = /^[\(\)\[\]\-\>\.\,\|]+/
const RE_WORD_ALIAS = /^alias/
const RE_ANYTHING_UNTIL_END = /^.+/s

Expand Down Expand Up @@ -141,7 +141,6 @@ export const tokenizeLine = (line, lineState) => {
token = TokenType.Text
state = State.TopLevelContent
} else {
part.startsWith('Bool') //?
throw new Error('no')
}
break
Expand Down Expand Up @@ -182,6 +181,7 @@ export const tokenizeLine = (line, lineState) => {
state = State.AfterKeywordModule
break
case 'port':
case 'as':
token = TokenType.Keyword
state = State.TopLevelContent
break
Expand Down
9 changes: 9 additions & 0 deletions test/baselines/import-dot.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
KeywordImport
Whitespace
VariableName
Punctuation
VariableName
Whitespace
Keyword
Whitespace
VariableName
3 changes: 1 addition & 2 deletions test/baselines/module.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ VariableName
Whitespace
KeywordImport
Whitespace
Punctuation
Text
Punctuation
3 changes: 1 addition & 2 deletions test/baselines/port-module.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ VariableName
Whitespace
KeywordImport
Whitespace
Punctuation
Text
Punctuation
1 change: 1 addition & 0 deletions test/cases/import-dot.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Api.Endpoint as Endpoint

0 comments on commit 3449d54

Please sign in to comment.