Skip to content

Commit 96ae406

Browse files
committed
fix(launcher): Completion requests now submit the ID of the active option
1 parent 1eee9fc commit 96ae406

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

src/dialog_launcher.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,19 @@ export class Launcher extends search.Search {
279279
};
280280

281281
let complete = (): boolean => {
282-
if (this.last_plugin) {
283-
plugins.Plugin.complete(ext, this.last_plugin)
284-
const res = plugins.Plugin.listen(this.last_plugin)
285-
if (res && res.event === "fill") {
286-
this.set_text(res.text)
287-
return true
282+
const option = this.options[this.active_id]
283+
if (option) {
284+
if ("plugin" in option.id) {
285+
const { plugin, id } = option.id
286+
plugins.Plugin.complete(ext, plugin, id);
287+
const res = plugins.Plugin.listen(plugin)
288+
if (res && res.event === "fill") {
289+
this.set_text(res.text)
290+
return true
291+
}
288292
}
289293
}
294+
290295
return false
291296
}
292297

src/dialog_search.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export class Search {
2525
shouldFadeOut: false
2626
});
2727

28-
private active_id: number;
28+
active_id: number;
29+
2930
private entry: St.Entry;
3031
private list: St.Widget;
3132
private text: Clutter.Text;

src/launcher_plugins.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export namespace Request {
5454

5555
export interface Complete {
5656
event: 'complete',
57+
id: number,
5758
}
5859

5960
export interface Submit {
@@ -188,8 +189,8 @@ export namespace Plugin {
188189
}
189190
}
190191

191-
export function complete(ext: Ext, plugin: Plugin.Source): boolean {
192-
return send(ext, plugin, { event: "complete" })
192+
export function complete(ext: Ext, plugin: Plugin.Source, id: number): boolean {
193+
return send(ext, plugin, { event: "complete", id })
193194
}
194195

195196
export function query(ext: Ext, plugin: Plugin.Source, value: string): boolean {

src/plugins/files/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ class App {
3636

3737
/**
3838
* Performs tab completion based on the last-given search query.
39+
*
40+
* @param {number} id
3941
*/
40-
complete() {
42+
complete(id) {
4143
let text
4244

43-
const selected = this.selections[0]
45+
const selected = this.selections[id]
4446
if (selected) {
4547
text = selection_path(this.parent, selected)
4648
} else {
@@ -207,7 +209,7 @@ function main() {
207209
if ((event_ = parse_event(input_str)) !== null) {
208210
switch (event_.event) {
209211
case "complete":
210-
app.complete()
212+
app.complete(event_.id)
211213
break
212214
case "query":
213215
if (event_.value) app.query(event_.value)

0 commit comments

Comments
 (0)