Position of error marks is adjusted for selection.

Close: #20
This commit is contained in:
eelke 2018-11-10 10:59:52 +01:00
parent b0718258c9
commit f629e48a85
5 changed files with 21 additions and 13 deletions

View file

@ -100,6 +100,8 @@ void ConnectionList::remove(size_t idx, size_t count)
auto l = f + static_cast<int>(count);
deleteFromIni(f, l);
m_connections.erase(f, l);
// remove from password save
}
void ConnectionList::deleteFromIni(t_Connections::iterator begin, t_Connections::iterator end)

View file

@ -187,7 +187,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">

View file

@ -4,7 +4,6 @@
#include "SqlSyntaxHighlighter.h"
#include <QStandardPaths>
#include <QPushButton>
#include <QAction>
#include <QFileDialog>
#include <QStatusBar>
@ -529,10 +528,20 @@ void QueryTab::query_ready(Expected<std::shared_ptr<Pgsql::Result>> 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);
}
}

View file

@ -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

View file

@ -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