Skip to content

Commit 021afd4

Browse files
committed
Get the correct identifier for auto-completion
1 parent 7493f5f commit 021afd4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/LuaConsole.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,15 @@ static std::string getLuaIdentifierAt(GUI::ScintillaWindow *sw, int pos) {
113113

114114
Sci_TextToFind ttf = {
115115
{
116-
sw->Call(SCI_POSITIONFROMLINE, line),
117-
pos
116+
// Search backwards
117+
pos,
118+
sw->Call(SCI_POSITIONFROMLINE, line)
118119
},
119120
"[a-z_][a-z0-9_]*(\\.[a-z_][a-z0-9_]*)*",
120121
};
121122

122-
if (sw->CallPointer(SCI_FINDTEXT, SCFIND_REGEXP, &ttf) != -1)
123+
// Only return the range if it ends at pos
124+
if (sw->CallPointer(SCI_FINDTEXT, SCFIND_REGEXP, &ttf) != -1 && ttf.chrgText.cpMax == pos)
123125
return getRange(sw, ttf.chrgText.cpMin, ttf.chrgText.cpMax);
124126
else
125127
return std::string();
@@ -135,7 +137,6 @@ static std::string join(const std::vector<T> &v, const U &delim) {
135137
return ss.str();
136138
}
137139

138-
139140
static void setStyles(GUI::ScintillaWindow &sci) {
140141
sci.Call(SCI_SETEOLMODE, SC_EOL_CRLF, 0);
141142

0 commit comments

Comments
 (0)