diff --git a/CHANGELOG.md b/CHANGELOG.md
index 638e9d9..cf1666d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
-----
diff --git a/fish.YAML-tmLanguage b/fish.YAML-tmLanguage
index 0b831c1..67b2437 100644
--- a/fish.YAML-tmLanguage
+++ b/fish.YAML-tmLanguage
@@ -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:
@@ -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:
@@ -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:
@@ -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:
@@ -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
@@ -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:
@@ -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;&)])
@@ -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:
@@ -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
@@ -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
@@ -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;])
@@ -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
diff --git a/fish.tmLanguage b/fish.tmLanguage
index fe7d3d1..fc44b3d 100644
--- a/fish.tmLanguage
+++ b/fish.tmLanguage
@@ -798,7 +798,7 @@
comment
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
end
- end(?=[\s;&)|<>])
+ end(?=$|[\s;&)|<>])
endCaptures
0
@@ -823,7 +823,7 @@
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(?=$|[\s;&)|<>])
endCaptures
0
@@ -882,7 +882,7 @@
comment
Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -899,7 +899,7 @@
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(?=$|[\s;&)|<>])
endCaptures
0
@@ -928,7 +928,7 @@
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(?=$|[\s;&)|<>])
endCaptures
0
@@ -1032,7 +1032,7 @@
comment
Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -1057,7 +1057,7 @@
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(?=$|[\s;&)|<>])
endCaptures
0
@@ -1152,7 +1152,7 @@
comment
Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -1221,7 +1221,7 @@
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(?=$|[\s;&)|<>])
endCaptures
0
@@ -1352,7 +1352,7 @@
comment
Anonymous scope - Capture the operator we know is there, include the base scope, and end when an `end` command is seen
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -1377,7 +1377,7 @@
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
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -1426,7 +1426,7 @@
comment
Anonymous scope - Match the operator we know is there, then include the base scope or an `else` structure
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -1435,7 +1435,7 @@
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
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns
@@ -1505,7 +1505,7 @@
comment
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
end
- (?=end[\s;&)|<>])
+ (?=end(?:$|[\s;&)|<>]))
patterns