mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 10:20:17 -06:00
Fix executing current SQL line not working always
If the last character was a semicolon and the cursor was placed after it, the Execute current line action didn't execute anything. It now execute the last SQL found
This commit is contained in:
@@ -865,13 +865,24 @@ void MainWindow::executeQuery()
|
||||
int position = editor->positionFromLineIndex(cursor_line, cursor_index);
|
||||
|
||||
QString entireSQL = editor->text();
|
||||
QString firstPartEntireSQL = entireSQL.left(position);
|
||||
QString secondPartEntireSQL = entireSQL.right(entireSQL.length() - position);
|
||||
|
||||
QString firstPartSQL = firstPartEntireSQL.split(";").last();
|
||||
QString lastPartSQL = secondPartEntireSQL.split(";").first();
|
||||
if (secondPartEntireSQL.trimmed().length() == 0) {
|
||||
position = entireSQL.lastIndexOf(";") - 1;
|
||||
}
|
||||
|
||||
query = firstPartSQL + lastPartSQL;
|
||||
if (position == -1) {
|
||||
query = entireSQL;
|
||||
} else {
|
||||
secondPartEntireSQL = entireSQL.right(entireSQL.length() - position);
|
||||
|
||||
QString firstPartEntireSQL = entireSQL.left(position);
|
||||
|
||||
QString firstPartSQL = firstPartEntireSQL.split(";").last();
|
||||
QString lastPartSQL = secondPartEntireSQL.split(";").first();
|
||||
|
||||
query = firstPartSQL + lastPartSQL;
|
||||
}
|
||||
} else {
|
||||
// if a part of the query is selected, we will only execute this part
|
||||
query = sqlWidget->getSelectedSql();
|
||||
|
||||
Reference in New Issue
Block a user