Skip to content

Commit

Permalink
fix: replace the word until the space and add a space to all providers
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Dec 1, 2023
1 parent 3abef2e commit 782f99b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/Dialogs/Composer/Completion/CompletionProvider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvi
this.is_capturing_input = state;
if (state) {
debug ("Capturing input");
}
else {
} else {
debug ("Stopped capturing input");
this.empty_triggers = 0;
}
Expand All @@ -36,10 +35,16 @@ public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvi
Gtk.TextIter start;
Gtk.TextIter end;
context.get_bounds (out start, out end);
end.forward_word_end ();

// Go forwards until we find a space
// aka get the full string - even if it's not considered a word
// by pango
end.forward_find_char ((e) => e.isspace (), null);
// plus a space since we are appending one below
end.forward_char ();

var buffer = start.get_buffer ();
var new_content = proposal.get_typed_text ();
var new_content = proposal.get_typed_text () + " ";

buffer.begin_user_action ();
buffer.@delete (ref start, ref end);
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/Composer/Completion/HandleProvider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Tuba.HandleProvider: Tuba.CompletionProvider {
}

public override string? get_typed_text () {
return this.account.handle.offset (1) + " ";
return this.account.handle.offset (1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/Composer/Completion/HashtagProvider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Tuba.HashtagProvider: Tuba.CompletionProvider {
}

public override string? get_typed_text () {
return this.tag.name + " ";
return this.tag.name;
}
}

Expand Down

0 comments on commit 782f99b

Please sign in to comment.