[TxMt] Re: SQL grammar help

Allan Odgaard mailinglist at textmate.org
Tue Nov 30 08:43:22 UTC 2010


On 29 Nov 2010, at 03:08, John DeSoi wrote:

> I want to be able to execute a multi-line SQL statement by placing the cursor anywhere in the statement OR immediately following the ending statement semi-colon. With the grammar fragment below everything seems to work fine except for the case where two statements are on consecutive lines:

The problem is that the scope of the caret is that of the character to the right of it. When you have the caret after the semi-colon then it uses the scope of the newline character.

You match this newline character in the end rule (\s), but that is also what means your lines appear merged (the meta.statement.pgsql scope span both lines since the newline is part of the scope).

Presently there is no simple fix for this. You could assign another scope to the newline making it work except when caret is to the right of the semi-colon. You could handle this case specially with another command (targetting that scope) — of course that command would lack the meta.statement.pgsql scope (as input) and would need to instead go by current line.

Another option is to modify your command to split up the expression read from stdin and cut after the semi-colon.



More information about the textmate mailing list