Skip to content

Commit

Permalink
Aways connect signals
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremypw committed Dec 20, 2024
1 parent d0fb053 commit f9749fe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/word-completion/plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable {

return Source.REMOVE;
});
} else {
connect_signals ();
}

// Always connect signals - they are disconnected in cleanup
connect_signals ();
}

// Runs before default handler so buffer text not yet modified. @pos must not be invalidated
Expand All @@ -142,7 +143,7 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable {
var text_to_add = (word_before + new_text + word_after);
var text_to_remove = (word_before + word_after);
// Only update if words have changed

debug ("insert text - add '%s' + '%s' + '%s'", word_before, new_text, word_after);
if (text_to_add != text_to_remove) {
parser.parse_text_and_add (text_to_add);
parser.remove_word (text_to_remove);
Expand All @@ -161,6 +162,7 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable {
var to_add = word_before + word_after;

// More than one word could be deleted so parse.
debug ("delete range - remove '%s' + '%s' + '%s'", word_before, del_text, word_after);
parser.parse_text_and_remove (to_remove);
// Only one at most new words
parser.add_word (to_add);
Expand Down

0 comments on commit f9749fe

Please sign in to comment.