From f629e48a852dcaab631e2a0136d4c5db99259e80 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 10 Nov 2018 10:59:52 +0100 Subject: [PATCH] Position of error marks is adjusted for selection. Close: #20 --- pglab/ConnectionList.cpp | 2 ++ pglab/ConnectionManagerWindow.ui | 2 +- pglab/QueryTab.cpp | 17 +++++++++++++---- pglab/pglab.pro | 11 ++++------- tests/pglabtests/pglabtests.pro | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pglab/ConnectionList.cpp b/pglab/ConnectionList.cpp index 9187697..2f7b48c 100644 --- a/pglab/ConnectionList.cpp +++ b/pglab/ConnectionList.cpp @@ -100,6 +100,8 @@ void ConnectionList::remove(size_t idx, size_t count) auto l = f + static_cast(count); deleteFromIni(f, l); m_connections.erase(f, l); + + // remove from password save } void ConnectionList::deleteFromIni(t_Connections::iterator begin, t_Connections::iterator end) diff --git a/pglab/ConnectionManagerWindow.ui b/pglab/ConnectionManagerWindow.ui index 839e9db..6ba5189 100644 --- a/pglab/ConnectionManagerWindow.ui +++ b/pglab/ConnectionManagerWindow.ui @@ -187,7 +187,7 @@ 0 0 800 - 20 + 21 diff --git a/pglab/QueryTab.cpp b/pglab/QueryTab.cpp index 69f98d1..f8ac60e 100644 --- a/pglab/QueryTab.cpp +++ b/pglab/QueryTab.cpp @@ -4,7 +4,6 @@ #include "SqlSyntaxHighlighter.h" #include #include - #include #include #include @@ -529,10 +528,20 @@ void QueryTab::query_ready(Expected> exp_res, qin void QueryTab::markError(const Pgsql::ErrorDetails &details) { - if (details.statementPosition > 0) { QTextCursor cursor = ui->queryEdit->textCursor(); - cursor.setPosition(details.statementPosition-1); + + // Following finds out the start of the current selection + // theoreticallly the selection might have changed however + // theoretically all the text might have changed also so we ignore + // both issues for know and we solve both when we decide it is to much of + // a problem but in practice syntax errors come back very quickly... + int position_offset = 0; + if (cursor.hasSelection()) { + position_offset = cursor.selectionStart(); + } + + cursor.setPosition(details.statementPosition - 1 + position_offset); ui->queryEdit->setTextCursor(cursor); int length = 0; @@ -554,7 +563,7 @@ void QueryTab::markError(const Pgsql::ErrorDetails &details) } } } - ui->queryEdit->addErrorMarker(details.statementPosition-1, length); + ui->queryEdit->addErrorMarker(details.statementPosition - 1 + position_offset, length); } } diff --git a/pglab/pglab.pro b/pglab/pglab.pro index 08070e0..ec3c9b4 100644 --- a/pglab/pglab.pro +++ b/pglab/pglab.pro @@ -22,13 +22,6 @@ DEFINES += _WIN32_WINNT=0x0501 #LIBS += -LC:/prog/boost/lib -Lc:/prog/lib libpq.lib fmt.lib User32.lib ws2_32.lib #LIBS += -LC:\VSproj\boost32\lib -LC:/PROG/LIB -lws2_32 -llibpq -#debug { -LIBS += c:/prog/lib/botan_imp.lib -#} - -#release { -#LIBS += c:/prog/lib/botan.lib -#} win32:RC_ICONS += pglab.ico @@ -166,6 +159,10 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../core/debug/ -lco INCLUDEPATH += $$PWD/../core DEPENDPATH += $$PWD/../core +win32:CONFIG(release, debug|release): LIBS += c:/prog/lib/botand.lib +else:win32:CONFIG(debug, debug|release): LIBS += c:/prog/lib/botan.lib + + win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../core/release/libcore.a else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../core/debug/libcore.a else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../core/release/core.lib diff --git a/tests/pglabtests/pglabtests.pro b/tests/pglabtests/pglabtests.pro index 3a9ad20..c19bbc9 100644 --- a/tests/pglabtests/pglabtests.pro +++ b/tests/pglabtests/pglabtests.pro @@ -39,7 +39,7 @@ C:\VSproj\boost32\include INCLUDEPATH += $$PWD/../../core DEPENDPATH += $$PWD/../../core -LIBS += c:\prog\lib\botan_imp.lib +LIBS += c:\prog\lib\botand.lib win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../core/release/libcore.a else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../core/debug/libcore.a