extensionUtils: Support subdirectories in getCurrentExtension
Some extensions may have complex layouts with multiple subdirectories. Currently, getCurrentExtension doesn't support this, as it uses a regex and assume's that the last path's component's parent is all that's needed. Fix this. https://bugzilla.gnome.org/show_bug.cgi?id=677001
This commit is contained in:
parent
ad6d986172
commit
65d23fb9a3
@ -40,13 +40,18 @@ function getCurrentExtension() {
|
|||||||
throw new Error('Could not find current extension');
|
throw new Error('Could not find current extension');
|
||||||
|
|
||||||
let path = match[1];
|
let path = match[1];
|
||||||
let uuid = GLib.path_get_basename(GLib.path_get_dirname(path));
|
let file = Gio.File.new_for_path(path);
|
||||||
|
|
||||||
let extension = extensions[uuid];
|
// Walk up the directory tree, looking for an extesion with
|
||||||
if (extension === undefined)
|
// the same UUID as a directory name.
|
||||||
throw new Error('Could not find current extension');
|
while (file != null) {
|
||||||
|
let extension = extensions[file.get_basename()];
|
||||||
|
if (extension !== undefined)
|
||||||
|
return extension;
|
||||||
|
file = file.get_parent();
|
||||||
|
}
|
||||||
|
|
||||||
return extension;
|
throw new Error('Could not find current extension');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user