Skip to content

Commit

Permalink
fix #3731
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Jul 15, 2024
1 parent 1169528 commit 64f4125
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/latexcompleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class CompleterInputBinding: public QEditorInputBinding
} else if (getCurWord() == "") {
maxWritten = curStart + 1;
} else {
if (LatexCompleter::config && LatexCompleter::config->eowCompletes) {
if (LatexCompleter::config && LatexCompleter::config->eowCompletes && !completer->isCurrentWordUserConstruct()) {
insertCompletedWord();
}
QDocumentCursor edc = editor->cursor();
Expand Down Expand Up @@ -1970,6 +1970,17 @@ void LatexCompleter::setTab(int index)
tbAbove->setCurrentIndex(index);
}

bool LatexCompleter::isCurrentWordUserConstruct()
{
if (list->isVisible() && list->currentIndex().isValid()){
QVariant v = list->model()->data(list->currentIndex(), Qt::DisplayRole);
if (!v.isValid() || !v.canConvert<CompletionWord>()) return false;
CompletionWord cw = v.value<CompletionWord>();
return cw.type == CompletionWord::userConstruct;
}
return false;
}

void LatexCompleter::filterList(QString word, int showMostUsed)
{
QString cur = ""; //needed to preserve selection
Expand Down
2 changes: 2 additions & 0 deletions src/latexcompleter.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class LatexCompleter : public QObject
int countWords();
void setTab(int index); ///< bring given 'tab' to front

bool isCurrentWordUserConstruct(); ///< check if current word is a user construct

void insertText(QString txt); ///< insert 'txt'

void showTooltip(QString text); ///< show tooltip
Expand Down

0 comments on commit 64f4125

Please sign in to comment.