Skip to content

Commit 1bd06d2

Browse files
committed
Auto-insert with single suggestion now only works when triggered manually
1 parent 9c3720d commit 1bd06d2

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

TextEditor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4513,6 +4513,7 @@ void TextEditor::Autocomplete::setConfig(const AutoCompleteConfig* config) {
45134513

45144514
bool TextEditor::Autocomplete::startTyping(Cursors& cursors) {
45154515
if (!active && !requestActivation && configured && configuration.triggerOnTyping) {
4516+
triggeredManually = false;
45164517
start(cursors);
45174518
return true;
45184519

@@ -4528,6 +4529,7 @@ bool TextEditor::Autocomplete::startTyping(Cursors& cursors) {
45284529

45294530
bool TextEditor::Autocomplete::startShortcut(Cursors& cursors) {
45304531
if (!active && !requestActivation && configured && configuration.triggerOnShortcut) {
4532+
triggeredManually = true;
45314533
start(cursors);
45324534
return true;
45334535

@@ -4729,7 +4731,7 @@ bool TextEditor::Autocomplete::render(Document& document, Cursors& cursors, cons
47294731
requestDeactivation = true;
47304732
result = true;
47314733

4732-
} else if (configuration.autoInsertSingleSuggestions && state.suggestions.size() == 1) {
4734+
} else if (configuration.autoInsertSingleSuggestions && triggeredManually && state.suggestions.size() == 1) {
47334735
requestDeactivation = true;
47344736
result = true;
47354737
}

TextEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ class TextEditor {
495495
#endif
496496

497497
// see if single suggestions are automatically inserted
498+
// this only works when triggered manually
498499
bool autoInsertSingleSuggestions = false;
499500

500501
// delay in milliseconds between autocomplete trigger and suggestions popup
@@ -1116,6 +1117,7 @@ class TextEditor {
11161117
std::chrono::system_clock::time_point activationTime;
11171118
AutoCompleteConfig configuration;
11181119
AutoCompleteState state;
1120+
bool triggeredManually = false;
11191121
size_t currentSelection = 0;
11201122
static constexpr float suggestionWidth = 250.0f;
11211123

docs/autocomplete.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public:
4848
#endif
4949

5050
// see if single suggestions are automatically inserted
51+
// this only works when triggered manually
5152
bool autoInsertSingleSuggestions = false;
5253

5354
// delay in milliseconds between autocomplete trigger and suggestions popup

0 commit comments

Comments
 (0)