Bug: start end scoping in syntax definitions broken at file’s end

I have stumbled on an odd, but reproducible, issue with nested scopes while working on my fish language extension, where start end scopes matching at the end of the file (i.e. with no line break following) will not terminate correctly despite their end match being present. For this to happen, there needs to be a subscope contained within the start end scope that makes it skip a character that would otherwise be terminating it; proper termination is ignored after that.

This is easier shown than explained. Assuming the following syntax definition:

<?xml version="1.0" encoding="UTF-8"?>
<syntax name="buggsy">
    <meta>
        <name>Syntax Bug Collection</name>
        <type>structured</type>
        <preferred-file-extension>buggsy</preferred-file-extension>
    </meta>

    <scopes>
		<scope name="buggsy.quoted-double">
			<starts-with>
				<expression><![CDATA[(?x) "	]]></expression>
				<capture number="0" name="buggsy.string.quote-open" />
			</starts-with>
			<ends-with>
				<expression><![CDATA[(?x) "	]]></expression>
				<capture number="0" name="buggsy.string.quote-close" />
			</ends-with>
			<subscopes>
				<scope name="buggsy.escape">
					<expression><![CDATA[(?x) (\\)"	]]></expression>
					<capture number="1" name="buggsy.string.escape" />
				</scope>
			</subscopes>
		</scope>
    </scopes>
</syntax>

create a new file, assign it the “Syntax Bug Collection” syntax and type the following on the last line (taking care not to terminate it with a newline):

"a nice, unquoted string …"

Notice how both quotes are highlighted in your theme’s string highlight colour. Now edit the line to read:

"a nice, quoted \"string\" …"

Notice how only the opening quote and the first escape backslash are highlighted, while the second backslash and the closing quote are not. Inspecting the highlighting shows the buggsy.quoted-double scope extends to the end of the line. Adding anything (whitespace or non-whitespace) outside the quotes makes no difference.

Now add a trailing newline at the end of the string. Notice how all backslashes and both delimiting quotes are now highlighted. Inspecting reveals the scope now properly ends at the terminating quote.

Running Nova 5.1 (Revision 257074) on macOS 11.2.3 “Big Sur” (German locale)

Thank you for the report on this! We’ll look into getting this fixed soon.

I can confirm this issue is resolved in Nova 6.

Awesome! Thanks for the confirmation.