Fix autocomplete matching; fix #7543
I had broken it fixing some unicode issues with autocomplete recently.
This commit is contained in:
parent
3df4f89f3c
commit
520f32ff6c
1 changed files with 5 additions and 5 deletions
|
|
@ -96,14 +96,15 @@ public class ContactEntryCompletion : Gtk.EntryCompletion {
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return empty_addresses;
|
return empty_addresses;
|
||||||
|
|
||||||
int cursor_position = entry.cursor_position;
|
|
||||||
if (cursor_position < 0)
|
|
||||||
return empty_addresses;
|
|
||||||
|
|
||||||
string? original_text = entry.get_text();
|
string? original_text = entry.get_text();
|
||||||
if (original_text == null)
|
if (original_text == null)
|
||||||
return empty_addresses;
|
return empty_addresses;
|
||||||
|
|
||||||
|
int cursor_position = entry.cursor_position;
|
||||||
|
int cursor_offset = original_text.index_of_nth_char(cursor_position);
|
||||||
|
if (cursor_offset < 0)
|
||||||
|
return empty_addresses;
|
||||||
|
|
||||||
Gee.List<string> addresses = new Gee.ArrayList<string>();
|
Gee.List<string> addresses = new Gee.ArrayList<string>();
|
||||||
string delimiter = ",";
|
string delimiter = ",";
|
||||||
string[] addresses_array = original_text.split(delimiter);
|
string[] addresses_array = original_text.split(delimiter);
|
||||||
|
|
@ -116,7 +117,6 @@ public class ContactEntryCompletion : Gtk.EntryCompletion {
|
||||||
int bytes_seen_so_far = 0;
|
int bytes_seen_so_far = 0;
|
||||||
current_address_index = addresses.size - 1;
|
current_address_index = addresses.size - 1;
|
||||||
for (int i = 0; i < addresses.size; i++) {
|
for (int i = 0; i < addresses.size; i++) {
|
||||||
int cursor_offset = addresses[i].index_of_nth_char(cursor_position);
|
|
||||||
int token_bytes = addresses[i].length + delimiter.length;
|
int token_bytes = addresses[i].length + delimiter.length;
|
||||||
if ((bytes_seen_so_far + token_bytes) > cursor_offset) {
|
if ((bytes_seen_so_far + token_bytes) > cursor_offset) {
|
||||||
current_address_index = i;
|
current_address_index = i;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue