From 4d4b92697a23d520db5e827e223665b5ae4a3c41 Mon Sep 17 00:00:00 2001
From: Buckaroo Banzai <39065740+BuckarooBanzay@users.noreply.github.com>
Date: Tue, 1 Dec 2020 20:05:58 +0100
Subject: [PATCH] fix mismatched teleport/waypoint selection

---
 bridge/search.lua | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bridge/search.lua b/bridge/search.lua
index fac0f00..3da542b 100644
--- a/bridge/search.lua
+++ b/bridge/search.lua
@@ -91,8 +91,8 @@ local function show_formspec(playername, data)
 		return a.distance < b.distance
 	end)
 
-	-- store as last result
-	search_results[playername] = data
+	-- data to store as last result
+	local last_result_data = {}
 
 	-- render list items
 	for _, item in ipairs(data) do
@@ -140,6 +140,10 @@ local function show_formspec(playername, data)
 		item.description = description
 
 		if add_to_list then
+			-- result data
+			table.insert(last_result_data, item)
+			
+			-- formspec data
 			list = list .. "," ..
 				color .. "," ..
 				distance .. "," ..
@@ -150,6 +154,9 @@ local function show_formspec(playername, data)
 
 	end
 
+	-- store filtered result data
+	search_results[playername] = last_result_data
+
 	list = list .. ";]"
 
 	local teleport_button = ""
-- 
GitLab