Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

851 fix word completion logic #1487

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Detect when text gets inserted between a word
  • Loading branch information
colinkiama committed Nov 22, 2024
commit ab7fa7529949d0cce8c0b2792cf75c3f7b07585f
8 changes: 7 additions & 1 deletion plugins/word-completion/plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable {
return;
}

if (pos.ends_word ()) {
bool starts_word = pos.starts_word ();
bool ends_word = pos.ends_word ();
bool between_word = pos.inside_word () && !starts_word && !ends_word;

if (ends_word) {
this.handle_insert_at_phrase_end (pos, new_text, new_text_length);
} else if (between_word) {
debug ("word-completion: Text inserted between word.\n");
} else {
this.handle_insert_not_at_word_boundary (pos, new_text, new_text_length);
}
Expand Down