From b74c3c99e985ce01d03ab74da2300b20ed8ecf77 Mon Sep 17 00:00:00 2001 From: tom79 Date: Thu, 10 Aug 2017 17:43:51 +0200 Subject: [PATCH] Some other improvements for autocomplete --- .../fr/gouv/etalab/mastodon/activities/TootActivity.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 4bf92b4d2..9fb7467aa 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -957,7 +957,14 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc @Override public void onItemClick(AdapterView parent, View view, int position, long id) { Account account = accounts.get(position); - String deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition); + String deltaSearch = ""; + if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() ) + deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition); + else { + if( currentCursorPosition >= oldContent.length() ) + deltaSearch = oldContent.substring(currentCursorPosition-searchLength, oldContent.length()); + } + if( !search.equals("")) deltaSearch = deltaSearch.replace("@"+search,""); String newContent = oldContent.substring(0,currentCursorPosition-searchLength);