Better qualified completion support for quoted identifiers

The quotes around identifiers was hindering the automatic proposal of
fields when the table is completed or of tables when the schema name is
completed. By adding the dot surrounded by quotes (parent's end-quote and child's
begin-quote) as word separator, the child completion menu is activated
when the user presses the child's begin-quote.

See related issue #1433
This commit is contained in:
mgrojo
2018-09-09 15:09:38 +02:00
parent d0b5ff10a7
commit 04bc7da6e7

View File

@@ -1,6 +1,9 @@
#include <algorithm>
#include "SqlUiLexer.h"
#include "Qsci/qsciapis.h"
#include "Settings.h"
#include "sqlitetypes.h"
SqlUiLexer::SqlUiLexer(QObject* parent) :
QsciLexerSQL(parent)
@@ -184,9 +187,15 @@ QStringList SqlUiLexer::autoCompletionWordSeparators() const
{
// The only word separator for auto completion in SQL is "." as in "tablename.columnname".
// Because this isn't implemented in the default QScintilla SQL lexer for some reason we add it here.
// We also need to consider quoted identifiers as in "tablename"."columnname" with whatever quote character
// is configured.
QStringList wl;
wl << ".";
QString escapeSeparator = sqlb::escapeIdentifier(".");
// Case for non symetric quotes, e.g. "[.]" to "].["
std::reverse(escapeSeparator.begin(), escapeSeparator.end());
wl << "." << escapeSeparator;
return wl;
}