From 4cd09e4fc1dccc6297769c7218ca3fc90fe0c43b Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 7 Sep 2020 19:23:03 +0200 Subject: [PATCH] dont print if newer input --- ddg.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ddg.go b/ddg.go index f3219dc..7b4f79a 100644 --- a/ddg.go +++ b/ddg.go @@ -11,6 +11,10 @@ import ( "./rofi" ) +var ( + serial = 0 +) + func getSuggestions(query string) []string { param := url.Values{} param.Add("q", query) @@ -45,9 +49,16 @@ func handleSelect(input rofi.Input) { } func handleInputChange(input rofi.Input) { + serial++ + go genOutput(input, serial) +} + +func genOutput(input rofi.Input, mySerial int) { output := rofi.NewOutput() output.Lines = rofi.ConvertStringsToLine(getSuggestions(input.Value)) - rofi.SendOutput(output) + if serial == mySerial { + rofi.SendOutput(output) + } } func main() {