aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/AutoComplete.cxx1
-rw-r--r--src/AutoComplete.h2
-rw-r--r--src/ScintillaBase.cxx26
-rw-r--r--src/ScintillaBase.h1
4 files changed, 21 insertions, 9 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index 75e26fe28..00a3a75fc 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -16,6 +16,7 @@ AutoComplete::AutoComplete() {
posStart = 0;
strcpy(stopChars, "");
separator = ' ';
+ cancelAtStartPos = false;
}
AutoComplete::~AutoComplete() {
diff --git a/src/AutoComplete.h b/src/AutoComplete.h
index e4f8ade0d..96d061f50 100644
--- a/src/AutoComplete.h
+++ b/src/AutoComplete.h
@@ -14,6 +14,8 @@ public:
ListBox lb;
int posStart;
int startLen;
+ // Should autocompletion be canceled if editor's currentPos <= startPos?
+ bool cancelAtStartPos;
AutoComplete();
~AutoComplete();
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index ff2e001ec..f14426969 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -211,8 +211,10 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
}
rcList.bottom = rcList.top + heightAlloced;
ac.lb.SetPositionRelative(rcList, wMain);
- //lbAutoComplete.SetPosition(rcList);
ac.Show();
+ if (lenEntered != 0) {
+ AutoCompleteMoveToCurrentWord();
+ }
}
void ScintillaBase::AutoCompleteCancel() {
@@ -223,19 +225,25 @@ void ScintillaBase::AutoCompleteMove(int delta) {
ac.Move(delta);
}
+void ScintillaBase::AutoCompleteMoveToCurrentWord() {
+ char wordCurrent[1000];
+ int i;
+ int startWord = ac.posStart - ac.startLen;
+ for (i = startWord; i < currentPos; i++)
+ wordCurrent[i - startWord] = pdoc->CharAt(i);
+ wordCurrent[i - startWord] = '\0';
+ ac.Select(wordCurrent);
+}
+
void ScintillaBase::AutoCompleteChanged(char ch) {
- if (currentPos <= ac.posStart) {
+ if (currentPos <= ac.posStart - ac.startLen) {
+ ac.Cancel();
+ } else if (ac.cancelAtStartPos && currentPos <= ac.posStart) {
ac.Cancel();
} else if (ac.IsStopChar(ch)) {
ac.Cancel();
} else {
- char wordCurrent[1000];
- int i;
- int startWord = ac.posStart - ac.startLen;
- for (i = startWord; i < currentPos; i++)
- wordCurrent[i - startWord] = pdoc->CharAt(i);
- wordCurrent[i - startWord] = '\0';
- ac.Select(wordCurrent);
+ AutoCompleteMoveToCurrentWord();
}
}
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index 6344b17a3..a7aefd8bc 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -54,6 +54,7 @@ protected:
void AutoCompleteMove(int delta);
void AutoCompleteChanged(char ch=0);
void AutoCompleteCompleted();
+ void AutoCompleteMoveToCurrentWord();
virtual void CreateCallTipWindow(PRectangle rc) = 0;