Skip to content

Commit

Permalink
Auto triggering menu to is switched off for huge documents which reso…
Browse files Browse the repository at this point in the history
…lves dvorka#455.
  • Loading branch information
dvorka committed May 16, 2018
1 parent 5834951 commit 14dfae6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/src/qt/note_editor_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,18 @@ void NoteEditorView::keyPressEvent(QKeyEvent *event)

QPlainTextEdit::keyPressEvent(event);

// completion: letter must be handled~inserted first
// completion: letter must be handled~inserted first - now it's time to autocomplete
if(!completer->popup()->isVisible()) {
QChar k{event->key()};
if(k.isLetter()) {
// IMPROVE get configuration reference and setting - this must be fast
if(Configuration::getInstance().getMindState()==Configuration::MindState::THINKING) {
// TODO automatic completion suggestions when thinking - to be FIXED: doubled chars, backspace doesn't work, ...
if(performCompletion()) {
event->ignore();
MF_DEBUG("Document lines: " << blockCount() << endl);
if(blockCount() < Configuration::EDITOR_MAX_AUTOCOMPLETE_LINES) {
QChar k{event->key()};
if(k.isLetter()) {
// IMPROVE get configuration reference and setting - this must be fast
if(Configuration::getInstance().getMindState()==Configuration::MindState::THINKING) {
// TODO automatic completion suggestions when thinking - to be FIXED: doubled chars, backspace doesn't work, ...
if(performCompletion()) {
event->ignore();
}
}
}
}
Expand Down Expand Up @@ -320,8 +323,7 @@ void NoteEditorView::insertCompletion(const QString& completion, bool singleWord
= completion.length() - completer->completionPrefix().length();

// TODO single word completion to be removed
int insertionPosition
= cursor.position();
int insertionPosition = cursor.position();
cursor.insertText(completion.right(numberOfCharsToComplete));
if(singleWord) {
cursor.setPosition(insertionPosition);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/config/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class Configuration {
static constexpr const bool DEFAULT_MD_MATH = false;
static constexpr const bool DEFAULT_ALLOW_ONLINE_JS_LIBS = false;

static constexpr int EDITOR_MAX_AUTOCOMPLETE_LINES = 1000;

private:
explicit Configuration();

Expand Down

0 comments on commit 14dfae6

Please sign in to comment.