Skip to content

Commit

Permalink
Start to rework on_new_source_view
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Wootten authored and Jeremy Wootten committed Jan 31, 2025
1 parent fcd22c5 commit 49fc736
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions plugins/word-completion/plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,41 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable {

current_document = doc;
current_view = doc.source_view;

if (text_view_list.find (current_view) == null) {
text_view_list.append (current_view);
}

current_view.key_press_event.connect (on_key_press);

current_view.completion.show.connect (() => {
completion_in_progress = true;
});
current_view.completion.hide.connect (() => {
completion_in_progress = false;
});


if (text_view_list.find (current_view) == null)
text_view_list.append (current_view);

var comp_provider = new Scratch.Plugins.CompletionProvider (this);
comp_provider.priority = 1;
comp_provider.name = provider_name_from_document (doc);

current_completion = current_view.completion;
try {
current_view.completion.add_provider (comp_provider);
current_view.completion.show_headers = true;
current_view.completion.show_icons = true;
current_provider = new Scratch.Plugins.CompletionProvider (this);
current_provider.priority = 1;
current_provider.name = provider_name_from_document (doc);

current_completion.add_provider (current_provider);
current_completion.show_headers = true;
current_completion.show_icons = true;
current_completion.accelerators = 9;
current_completion.select_on_show = true;
/* Wait a bit to allow text to load then run parser*/
timeout_id = Timeout.add (1000, on_timeout_update);

} catch (Error e) {
warning (e.message);
critical (
"Could not add completion provider to %s. %s\n",
current_document.title,
e.message
);
cleanup (current_view);
return;
}
}

Expand Down

0 comments on commit 49fc736

Please sign in to comment.