Commit 20a75398 authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

gedit-plugin: improved multi-document sources

parent d0e76458
......@@ -38,8 +38,6 @@ public class GVls.GServer : GLib.Object, Server
}
public void parse (GLib.File file) throws GLib.Error {
if (source != null)
throw new ServerError.PARSER_ERROR ("There is an already parsed source");
if (!file.query_exists ())
throw new ServerError.NO_FILE_ERROR ("File doesn't exists: %s", file.get_path ());
var context = new Vala.CodeContext ();
......
......@@ -36,24 +36,29 @@ namespace GVlsEdit {
public void activate () {
cn = window.tab_added.connect ((tab)=>{
message ("New Tab Added");
var view = tab.get_view ();
init_view (view);
var doc = tab.get_document ();
doc.loaded.connect (()=>{
init_doc (doc);
});
});
}
public void deactivate () {
window.disconnect (cn);
}
public void update_state () {
foreach (Gedit.View view in window.get_views ()) {
init_view (view);
}
}
private void init_view (Gedit.View view) {
private void init_doc (Gedit.Document doc) {
var tab = Gedit.Tab.get_from_document (doc);
var view = tab.get_view ();
var prov = view.get_data<GVlsui.CompletionProvider> ("gvls-provider");
if (prov == null) return;
if (prov.server != null) return;
message ("Setting server for current tab");
prov.server = _server;
try {
message ("Document to parse: %s", doc.get_file ().location.get_uri ());
prov.current_server.parse (doc.get_file ().location);
prov.server = _server;
} catch (GLib.Error e) {
message ("Error parsing document: %s", e.message);
}
}
}
public class View : Peas.ExtensionBase, Gedit.ViewActivatable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment