pawelsalawa / sqlitestudio

A free, open source, multi-platform SQLite database manager.
https://sqlitestudio.pl
Other
5.1k stars 579 forks source link

"Run query" runs next query #3343

Open ysalmon opened 6 years ago

ysalmon commented 6 years ago

Details

In the SQL editor, when no text is selected, the "run query" tool (shortcut F9) uses the current text cursor position to determine which query should be executed.

If the cursor lies within a query, the executed query is bounded by the preceding and following query termination symbols ; (or begin/end of editor text).

An interesting and useful special case is if the cursor lies after the end of the last query of the editor : then the preceding query is executed. This goes well with a "type and execute" workflow.

However, the editor has an inconvenient behaviour when the text cursor is just after a query which is not the last one : then the general rules applies.

For example, if the whole text in the editor is the following (| represents cursor position)

select 1;|

I will get 1 as the result of the executed query, but if the text is the following

select 1;|

select 2;

I will get 2.

Proposal

That the preceding query, and not the following one, be executed when the text cursor lies after a ; and there is nothing but whitespace/comment until the next end-of-line character.

I also propose that after execution, the text cursor be moved to the end of the next query (if it exists) instead of selecting the text of the executed query, to avert risk of overwriting the query and so that pressing F9 several times in a row F9 progress through the queries.

pawelsalawa commented 6 years ago

Sounds reasonable.