Skip to content

Commit

Permalink
Fix bug where "end" at end of file wasn't highlighted correctly; closes
Browse files Browse the repository at this point in the history
  • Loading branch information
Phidica committed Jun 17, 2018
1 parent 4b25a43 commit 29382f5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ Changelog
-----

Bugfixes:
- ST2 would freeze encountering consecutive command substitutions
- ST2 would freeze encountering consecutive variable expansions
- ST2 would freeze encountering consecutive command substitutions (#14)
- ST2 would freeze encountering consecutive variable expansions (#14)
- `end` at end of file wasn't highlighted correctly (#15)

2.2.5
-----

Bugfixes:
- ST2 would freeze encountering an escaped newline
- ST2 would freeze encountering a pipe
- ST2 would freeze encountering an escaped newline (#14)
- ST2 would freeze encountering a pipe (#14)
- `not` wasn't recognised in a command chain

2.2.4
-----

Bugfix:
- Control characters appearing in brace expansion would freeze ST2
- Control characters appearing in brace expansion would freeze ST2 (#14)

2.2.3
-----
Expand Down
28 changes: 14 additions & 14 deletions fish.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ repository:
begin: begin(?=\s*[\n;]|\s+[^\s-])
beginCaptures:
'0': {name: keyword.control.conditional.fish}
end: end(?=[\s;&)|<>])
end: end(?=$|[\s;&)|<>])
endCaptures:
'0': {name: keyword.control.conditional.fish}
patterns:
Expand All @@ -483,7 +483,7 @@ repository:
- name: meta.block.while.fish
begin: (?=while\s+[^\s;)-])
comment: If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope
end: end(?=[\s;&)|<>])
end: end(?=$|[\s;&)|<>])
endCaptures:
'0': {name: keyword.control.conditional.fish}
patterns:
Expand All @@ -501,14 +501,14 @@ repository:
beginCaptures:
'1': {name: keyword.operator.fish}
'2': {name: invalid.illegal.operator.fish}
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- include: $self

- name: meta.block.if.fish
begin: (?=if\s+[^\s;)-])
comment: If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope
end: end(?=[\s;&)|<>])
end: end(?=$|[\s;&)|<>])
endCaptures:
'0': {name: keyword.control.conditional.fish}
patterns:
Expand All @@ -518,7 +518,7 @@ repository:
- name: meta.block.for-in.fish
begin: (?=for\s+[^\s;)-])
comment: If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope
end: end(?=[\s;&)|<>])
end: end(?=$|[\s;&)|<>])
endCaptures:
'0': {name: keyword.control.conditional.fish}
patterns:
Expand Down Expand Up @@ -554,7 +554,7 @@ repository:
beginCaptures:
'1': {name: keyword.operator.fish}
'2': {name: invalid.illegal.operator.fish}
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- include: $self

Expand All @@ -565,7 +565,7 @@ repository:
- name: meta.block.switch.fish
begin: (?=switch\s+[^\s;)-])
comment: If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope
end: end(?=[\s;&)|<>])
end: end(?=$|[\s;&)|<>])
endCaptures:
'0': {name: keyword.control.conditional.fish}
patterns:
Expand Down Expand Up @@ -599,7 +599,7 @@ repository:
beginCaptures:
'1': {name: keyword.operator.fish}
'2': {name: invalid.illegal.operator.fish}
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- comment: Anonymous scope - Capture the command name which might be there, include an arbitrary number of (forcibly nonoption) arguments, and end when the control operator is captured
begin: case(?=[\s;&)])
Expand All @@ -623,7 +623,7 @@ repository:
- name: meta.block.function.fish
begin: (?=function\s+[^\s;)-])
comment: If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope
end: end(?=[\s;&)|<>])
end: end(?=$|[\s;&)|<>])
endCaptures:
'0': {name: keyword.control.conditional.fish}
patterns:
Expand Down Expand Up @@ -669,7 +669,7 @@ repository:
beginCaptures:
'1': {name: keyword.operator.fish}
'2': {name: invalid.illegal.operator.fish}
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- include: $self

Expand All @@ -678,7 +678,7 @@ repository:
patterns:
- comment: Anonymous scope - Capture an `if` and the command up to the end-of-scope operator, then capture from the end-of-scope operator indefinitely
begin: (?=if(?:\s*\n|\s+[^\s;]))
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- comment: Anonymous scope - Match the command name we know is there, include a single instance of a command chain, and end when an operator is seen
begin: if
Expand All @@ -694,11 +694,11 @@ repository:
beginCaptures:
'1': {name: keyword.operator.fish}
'2': {name: invalid.illegal.operator.fish}
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- comment: Anonymous scope - Capture an `else` up to the end-of-scope operator or the start of an `if` structure, then match from the end-of-scope operator indefinitely or match an `if` structure
begin: (?=else\s*[\s;])
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- comment: Anonymous scope - Match the `else` we know is there and any comment, and mark anything besides an `if` as illegal
begin: else(?=\s*[\s;])
Expand All @@ -721,7 +721,7 @@ repository:
beginCaptures:
'1': {name: keyword.operator.fish}
'2': {name: invalid.illegal.operator.fish}
end: (?=end[\s;&)|<>])
end: (?=end(?:$|[\s;&)|<>]))
patterns:
- include: $self

Expand Down
28 changes: 14 additions & 14 deletions fish.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@
<key>comment</key>
<string>The begin command can be alone on a line or followed by any command that doesn't start with a '-'. If a '-' is seen it shouldn't be treated as a block</string>
<key>end</key>
<string>end(?=[\s;&amp;)|&lt;&gt;])</string>
<string>end(?=$|[\s;&amp;)|&lt;&gt;])</string>
<key>endCaptures</key>
<dict>
<key>0</key>
Expand All @@ -823,7 +823,7 @@
<key>comment</key>
<string>If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope</string>
<key>end</key>
<string>end(?=[\s;&amp;)|&lt;&gt;])</string>
<string>end(?=$|[\s;&amp;)|&lt;&gt;])</string>
<key>endCaptures</key>
<dict>
<key>0</key>
Expand Down Expand Up @@ -882,7 +882,7 @@
<key>comment</key>
<string>Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand All @@ -899,7 +899,7 @@
<key>comment</key>
<string>If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope</string>
<key>end</key>
<string>end(?=[\s;&amp;)|&lt;&gt;])</string>
<string>end(?=$|[\s;&amp;)|&lt;&gt;])</string>
<key>endCaptures</key>
<dict>
<key>0</key>
Expand Down Expand Up @@ -928,7 +928,7 @@
<key>comment</key>
<string>If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope</string>
<key>end</key>
<string>end(?=[\s;&amp;)|&lt;&gt;])</string>
<string>end(?=$|[\s;&amp;)|&lt;&gt;])</string>
<key>endCaptures</key>
<dict>
<key>0</key>
Expand Down Expand Up @@ -1032,7 +1032,7 @@
<key>comment</key>
<string>Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand All @@ -1057,7 +1057,7 @@
<key>comment</key>
<string>If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope</string>
<key>end</key>
<string>end(?=[\s;&amp;)|&lt;&gt;])</string>
<string>end(?=$|[\s;&amp;)|&lt;&gt;])</string>
<key>endCaptures</key>
<dict>
<key>0</key>
Expand Down Expand Up @@ -1152,7 +1152,7 @@
<key>comment</key>
<string>Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -1221,7 +1221,7 @@
<key>comment</key>
<string>If the command name is followed by a valid string (not anything that closes the scope or a string starting with a '-') then open the scope</string>
<key>end</key>
<string>end(?=[\s;&amp;)|&lt;&gt;])</string>
<string>end(?=$|[\s;&amp;)|&lt;&gt;])</string>
<key>endCaptures</key>
<dict>
<key>0</key>
Expand Down Expand Up @@ -1352,7 +1352,7 @@
<key>comment</key>
<string>Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand All @@ -1377,7 +1377,7 @@
<key>comment</key>
<string>Anonymous scope - Capture an `if` and the command up to the end-of-scope operator, then capture from the end-of-scope operator indefinitely</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -1426,7 +1426,7 @@
<key>comment</key>
<string>Anonymous scope - Match the operator we know is there, then include the base scope or an `else` structure</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand All @@ -1435,7 +1435,7 @@
<key>comment</key>
<string>Anonymous scope - Capture an `else` up to the end-of-scope operator or the start of an `if` structure, then match from the end-of-scope operator indefinitely or match an `if` structure</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -1505,7 +1505,7 @@
<key>comment</key>
<string>Anonymous scope - Match the operator which will be there if no `if` was seen, then include the base scope which marks further `else` commands as invalid</string>
<key>end</key>
<string>(?=end[\s;&amp;)|&lt;&gt;])</string>
<string>(?=end(?:$|[\s;&amp;)|&lt;&gt;]))</string>
<key>patterns</key>
<array>
<dict>
Expand Down

0 comments on commit 29382f5

Please sign in to comment.