Skip to content

Commit

Permalink
repalce tag from cursor pos - current tag length
Browse files Browse the repository at this point in the history
  • Loading branch information
NO-ob committed Jan 17, 2023
1 parent 8d81807 commit 7033e7a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/src/widgets/search/tag_search_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class _TagSearchBoxState extends State<TagSearchBox> {
String replaceString = "";
int startIndex = 0;
int multiIndex = -1;
int cursorPos = 0;
List<String> splitInput = [];

RxList<List<String>> booruResults = RxList([]);
Expand Down Expand Up @@ -320,7 +321,7 @@ class _TagSearchBoxState extends State<TagSearchBox> {
}

void setSelectedTag(String input){
int cursorPos = searchHandler.searchTextController.selection.baseOffset;
cursorPos = searchHandler.searchTextController.selection.baseOffset;
if (cursorPos < 0) cursorPos = 0;
int tmpStartIndex = cursorPos - 1;
while(
Expand Down Expand Up @@ -523,7 +524,8 @@ class _TagSearchBoxState extends State<TagSearchBox> {

String newInput = "";
if (startIndex >= 0 && replaceString.isNotEmpty){
newInput = searchHandler.searchTextController.text.replaceFirst(replaceString, newTag, startIndex);
//newInput = searchHandler.searchTextController.text.replaceRange(start, end, replacement)
newInput = searchHandler.searchTextController.text.replaceFirst(replaceString, newTag, cursorPos - replaceString.length);
} else if (startIndex == -1){
newInput = newTag + (searchHandler.currentBooru.type == "Hydrus" ? "," : " ") + searchHandler.searchTextController.text;
} else {
Expand Down

0 comments on commit 7033e7a

Please sign in to comment.