GSoC: GNOME Builder: Improving word completion

- 1 min

A relatively short update about the project. I have implemented a new GtkSourceCompletionProvider to mimick user- requested word-completion feature in Vim.

The word prefix is extracted from the buffer and a search query is generated using GtkSourceSearchSetting. The word prefix is essentially turned to a regex of the kind (prefix)[a-zA-Z0-9_]* . This will provide us with all related completion with the prefix.

The GtkSourceSearchSetting is regex and word boundaries enabled. Next step is to set the regex as the search text and navigate all the occurrence of the regex match using gtk_source_search_context_forward_async.

The matched text (proposals for the given prefix) can be retrived using gtk_text_iter_get_text (&match_start, &match_end) in the gtk_source_search_context_forward_async’s callback. Finally, make a new GtkSourceCompletionProposal instance for every match occurrence and add to a GList. Pass the GList to GtkSourceCompletionContext using gtk_source_completion_context_add_proposals to show the proposals in the completion window.

A short working demo is here:

Next steps is to smoothen some edges, score the proposals based on insertion cursor offset, remove duplicates and listening for the cancellation signal to stop the buffer scans.

Umang Jain

Umang Jain

Makes the machines talk

comments powered by Disqus
rss facebook twitter github youtube mail spotify instagram linkedin google pinterest medium