Fix off-zero auto-completion
This commit is contained in:
parent
5b4d8c9413
commit
10bb155b94
|
@ -1,3 +1,4 @@
|
||||||
|
#include <iostream>
|
||||||
/*
|
/*
|
||||||
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
|
@ -76,21 +77,22 @@ SendTextView::_AutoComplete()
|
||||||
// Now to find the substitutes
|
// Now to find the substitutes
|
||||||
BString substitution;
|
BString substitution;
|
||||||
if (fCurrentWord.StartsWith("/") == true) {
|
if (fCurrentWord.StartsWith("/") == true) {
|
||||||
substitution = _NextMatch(_CommandNames(), fCurrentWord.RemoveFirst("/"));
|
substitution =
|
||||||
if (substitution.IsEmpty() == true)
|
_NextMatch(_CommandNames(), BString(fCurrentWord).RemoveFirst("/"));
|
||||||
|
if (substitution.IsEmpty() == false)
|
||||||
substitution.Prepend("/");
|
substitution.Prepend("/");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
substitution = _NextMatch(_UserNames(), fCurrentWord);
|
substitution = _NextMatch(_UserNames(), fCurrentWord);
|
||||||
|
|
||||||
// Apply the substitution
|
// Apply the substitution or jet off
|
||||||
if (substitution.IsEmpty() == true)
|
if (substitution.IsEmpty() == true)
|
||||||
fCurrentIndex = 0;
|
fCurrentIndex = 0;
|
||||||
else {
|
else {
|
||||||
int32 index = text.FindLast(lastWord);
|
int32 index = text.FindLast(lastWord);
|
||||||
int32 newindex = index + substitution.Length();
|
int32 newindex = index + substitution.Length();
|
||||||
|
|
||||||
Delete(index, lastWord.CountChars());
|
Delete(index, index + lastWord.CountChars());
|
||||||
Insert(index, substitution, substitution.Length());
|
Insert(index, substitution, substitution.Length());
|
||||||
Select(newindex, newindex);
|
Select(newindex, newindex);
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue