From 06202b9b31d90502d4957975b50c1f1c981e885a Mon Sep 17 00:00:00 2001 From: wowaddonmaker Date: Sun, 15 Mar 2026 20:55:29 -0400 Subject: [PATCH] Fix all luacheck warnings, add LICENSE --- .luacheckrc | 13 ++++++++++ Database.lua | 58 ++++++++++++++++++--------------------------- Highlight.lua | 15 ++++-------- LICENSE | 8 +++++++ MapSearch.lua | 44 ++++++++++------------------------ Options.lua | 4 +--- Rescaler.lua | 49 ++++---------------------------------- StaticLocations.lua | 2 +- UI.lua | 41 ++++++++++---------------------- Utils.lua | 4 ++-- 10 files changed, 81 insertions(+), 157 deletions(-) create mode 100644 LICENSE diff --git a/.luacheckrc b/.luacheckrc index 8bdfb33..c68c426 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -66,9 +66,22 @@ read_globals = { "C_Reputation", "C_SuperTrack", "C_TaxiMap", "C_Texture", "C_Timer", "C_ToyBox", "C_VignetteInfo", + -- UI utility functions + "UIFrameFadeIn", "UIFrameFadeOut", "UIFrameFadeRemoveFrame", + "AchievementFrameCategories_SelectElementData", + "UnitPopup_ShowMenu", "BattlePetToolTip_ShowLink", + "GetUnitSpeed", "GetItemCooldown", "EJ_GetInstanceInfo", + + -- Data types + "UiMapPoint", + + -- Cross-addon references + "EasyFindDevDB", + -- Constants, Enums, Mixins "Enum", "Settings", "BackdropTemplateMixin", "SOUNDKIT", "UIDROPDOWNMENU_OPEN_MENU", "UISpecialFrames", + "FACTION_BAR_COLORS", "LE_PET_JOURNAL_FILTER_COLLECTED", "LE_PET_JOURNAL_FILTER_NOT_COLLECTED", -- Font objects diff --git a/Database.lua b/Database.lua index 1656843..41b04bc 100644 --- a/Database.lua +++ b/Database.lua @@ -1,17 +1,14 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local Database = {} ns.Database = Database local Utils = ns.Utils -local pairs, ipairs, type = Utils.pairs, Utils.ipairs, Utils.type -local tinsert, tsort, tconcat = Utils.tinsert, Utils.tsort, Utils.tconcat +local ipairs = Utils.ipairs +local tsort, tconcat = Utils.tsort, Utils.tconcat local sfind, slower, ssub = Utils.sfind, Utils.slower, Utils.ssub local mmin, mmax, mabs = Utils.mmin, Utils.mmax, Utils.mabs -local unpack = Utils.unpack - local C_CurrencyInfo = C_CurrencyInfo -local wipe = wipe -- Word split cache: avoids per-call gmatch + table creation in scoring hot path. -- Key = lowercase string, value = array of words split on [%w']+. @@ -373,9 +370,9 @@ function Database:PopulateDynamicReputations() -- Collapse back any headers we expanded during scanning for pass = 1, 50 do - local numFactions = C_Reputation.GetNumFactions() + local numFactionsPost = C_Reputation.GetNumFactions() local didCollapse = false - for i = numFactions, 1, -1 do + for i = numFactionsPost, 1, -1 do local factionData = C_Reputation.GetFactionDataByIndex(i) if factionData and factionData.isHeader and headersWeExpanded[factionData.name] then -- Check if header is expanded using both property names @@ -436,8 +433,8 @@ function Database:PopulateDynamicMounts() if not mountIDs then return end for _, mountID in ipairs(mountIDs) do - local name, spellID, icon, isActive, isUsable, sourceType, isFavorite, - isFactionSpecific, faction, shouldHideOnChar, isCollected = C_MountJournal.GetMountInfoByID(mountID) + local name, spellID, icon, _, _, _, _, + _, _, shouldHideOnChar, isCollected = C_MountJournal.GetMountInfoByID(mountID) if name and isCollected and not shouldHideOnChar then uiSearchData[#uiSearchData + 1] = setmetatable({ name = name, @@ -520,7 +517,7 @@ function Database:PopulateDynamicPets() local seen = {} for i = 1, numPets do - local petID, speciesID, owned, customName, level, favorite, isRevoked, + local petID, speciesID, owned, _, _, _, _, speciesName, icon = C_PetJournal.GetPetInfoByIndex(i) if speciesName and speciesName ~= "" and owned and not seen[speciesID] then seen[speciesID] = true @@ -1443,7 +1440,7 @@ function Database:BuildUIDatabase() name = "Reset All Instances", keywords = {"reset instances", "reset all instances", "instance reset", "dungeon reset"}, available = function() - local inInstance, instanceType = IsInInstance() + local inInstance = IsInInstance() if inInstance then return false end if IsInGroup() and not UnitIsGroupLeader("player") then return false end return true @@ -2051,25 +2048,20 @@ function Database:SearchUI(query, skipCategories) local searchCount = #searchSet for i = 1, searchCount do local data = searchSet[i] - -- Skip entries whose category is filtered out (Mount/Toy items only) - if skipCategories and skipCategories[data.category] then - -- Filtered out by user preference, skip entirely - -- Skip entries that have an availability check that returns false - elseif data.available and not data.available() then - -- Not available in current context, skip - else - local nameLower = data.nameLower - local score = Database:ScoreName(nameLower, query, queryLen, queryWords) - - -- Keyword matching (additive) - score = score + Database:ScoreKeywords(data.keywordsLower, query, queryLen, queryWords) - - if score >= 30 then - results[#results + 1] = { data = data, score = score } - candidateIdx = candidateIdx + 1 - prevCandidates[candidateIdx] = data + if not (skipCategories and skipCategories[data.category]) + and not (data.available and not data.available()) then + local nameLower = data.nameLower + local score = Database:ScoreName(nameLower, query, queryLen, queryWords) + + -- Keyword matching (additive) + score = score + Database:ScoreKeywords(data.keywordsLower, query, queryLen, queryWords) + + if score >= 30 then + results[#results + 1] = { data = data, score = score } + candidateIdx = candidateIdx + 1 + prevCandidates[candidateIdx] = data + end end - end -- else (availability check) end -- Trim stale entries from previous search for i = candidateIdx + 1, #prevCandidates do @@ -2271,10 +2263,7 @@ function Database:BuildHierarchicalResults(results) local child = node.children[childName] local hasChildren = #child.childOrder > 0 - -- Skip empty path nodes (no data and no content in descendants) - if not hasActualContent(child) then - -- Skip this entire branch - else + if hasActualContent(child) then -- Check if this leaf node is actually a container in the database -- (has children that didn't match the search query). local isContainer = false @@ -2314,7 +2303,6 @@ function Database:GetContainerChildren(containerData) local prefix = {} for _, p in ipairs(containerData.path) do prefix[#prefix + 1] = p end prefix[#prefix + 1] = containerData.name - local prefixKey = tconcat(prefix, "\1") local prefixLen = #prefix local children = {} diff --git a/Highlight.lua b/Highlight.lua index 8f96e81..18740ce 100644 --- a/Highlight.lua +++ b/Highlight.lua @@ -1,20 +1,16 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local Highlight = {} ns.Highlight = Highlight local Utils = ns.Utils local GetButtonText = Utils.GetButtonText -local IsButtonSelected = Utils.IsButtonSelected -local SearchFrameTree = Utils.SearchFrameTree local SearchFrameTreeFuzzy = Utils.SearchFrameTreeFuzzy -local GetAllFrameText = Utils.GetAllFrameText local ScrollBoxScrollTo = Utils.ScrollBoxScrollTo local ScrollBoxFindButton = Utils.ScrollBoxFindButton -local ClickButton = Utils.ClickButton -local select, ipairs, pairs = Utils.select, Utils.ipairs, Utils.pairs -local sfind, slower, sformat = Utils.sfind, Utils.slower, Utils.sformat -local mmin, mmax, mabs, mpi = Utils.mmin, Utils.mmax, Utils.mabs, Utils.mpi +local select, ipairs = Utils.select, Utils.ipairs +local sfind, slower = Utils.sfind, Utils.slower +local mmax, mpi = Utils.mmax, Utils.mpi local pcall = Utils.pcall local GOLD_COLOR = ns.GOLD_COLOR @@ -25,9 +21,6 @@ local CreateFrame = CreateFrame local C_Timer = C_Timer local GetTime = GetTime local UIParent = UIParent -local hooksecurefunc = hooksecurefunc -local wipe = wipe -local strsplit = strsplit local HOVER_MIN_DISPLAY = 0.3 -- seconds the highlight must be visible before hover clears it diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b7147b7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +Copyright (c) 2026. All rights reserved. + +This software and associated files may not be copied, modified, merged, +published, distributed, sublicensed, or sold without prior written +permission from the copyright holder. + +Use of this software is permitted only as distributed through official +channels (CurseForge, GitHub Releases). diff --git a/MapSearch.lua b/MapSearch.lua index 01a90cc..3f2d9a7 100644 --- a/MapSearch.lua +++ b/MapSearch.lua @@ -1,4 +1,4 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local MapSearch = {} ns.MapSearch = MapSearch @@ -7,8 +7,8 @@ local Utils = ns.Utils local DebugPrint = Utils.DebugPrint local pairs, ipairs, type, select = Utils.pairs, Utils.ipairs, Utils.type, Utils.select local tinsert, tsort, tconcat, tremove = Utils.tinsert, Utils.tsort, Utils.tconcat, Utils.tremove -local sfind, slower, sformat = Utils.sfind, Utils.slower, Utils.sformat -local mmin, mmax, mabs, mpi, mfloor, msin = Utils.mmin, Utils.mmax, Utils.mabs, Utils.mpi, Utils.mfloor, math.sin +local sfind, slower = Utils.sfind, Utils.slower +local mmin, mmax, mpi = Utils.mmin, Utils.mmax, Utils.mpi local pcall, tostring = Utils.pcall, Utils.tostring local GOLD_COLOR = ns.GOLD_COLOR @@ -27,15 +27,11 @@ local IsShiftKeyDown = IsShiftKeyDown local IsMouseButtonDown = IsMouseButtonDown local hooksecurefunc = hooksecurefunc local wipe = wipe -local strsplit = strsplit -- Cache C_* API functions at file scope to get unhooked copies local GetMapInfo = C_Map.GetMapInfo -local GetMapGroupID = C_Map.GetMapGroupID -local GetMapGroupMembersInfo = C_Map.GetMapGroupMembersInfo local GetMapChildrenInfo = C_Map.GetMapChildrenInfo local GetBestMapForUnit = C_Map.GetBestMapForUnit -local GetPlayerMapPosition = C_Map.GetPlayerMapPosition local GetMapInfoAtPosition = C_Map.GetMapInfoAtPosition local SetUserWaypoint = C_Map.SetUserWaypoint local GetAreaPOIForMap = C_AreaPoiInfo and C_AreaPoiInfo.GetAreaPOIForMap @@ -44,7 +40,6 @@ local GetDelvesForMap = C_AreaPoiInfo and C_AreaPoiInfo.GetDelvesForMap local GetVignettePosition = C_VignetteInfo and C_VignetteInfo.GetVignettePosition local GetTaxiNodesForMap = C_TaxiMap and C_TaxiMap.GetTaxiNodesForMap local GetDungeonEntrancesForMap = C_EncounterJournal and C_EncounterJournal.GetDungeonEntrancesForMap -local GetDungeonEntranceMapInfo = C_EncounterJournal and C_EncounterJournal.GetDungeonEntranceMapInfo local HasUserWaypoint = C_Map.HasUserWaypoint local ClearUserWaypoint = C_Map.ClearUserWaypoint local GetUserWaypoint = C_Map.GetUserWaypoint @@ -262,7 +257,7 @@ function ns.UpdateIndicator(parentFrame) tex:SetTexCoord(0, 1, 0, 1) end -- Use directional override if set, otherwise use style default - local indicatorRotation = 0 + local indicatorRotation if parentFrame.indicatorDirection then indicatorRotation = ns.GetDirectionalRotation(parentFrame.indicatorDirection) elseif style.rotation then @@ -329,7 +324,6 @@ local TEXT_WRAP_FRACTION = 0.85 local SCROLL_CENTER_FRACTION = 0.95 local highlightFrame local indicatorFrame -local currentHighlightedPin local waypointPin local zoneHighlightFrame -- For highlighting zones on continent maps local isGlobalSearch = false -- Tracks which search bar triggered the current search @@ -354,7 +348,7 @@ local waypointController -- Invisible controller that drives OnUpdate -- MINIMAP WAYPOINT TRACKER - perimeter glow (far) + ring/arrow (near) -local matan2, mcos, msin, msqrt = math.atan2, math.cos, math.sin, math.sqrt +local matan2, mcos, msin = math.atan2, math.cos, math.sin local GetPlayerFacing = GetPlayerFacing local UnitPosition = UnitPosition local NEAR_RING_RADIUS = 28 -- pixels from minimap center to ring edge @@ -1726,7 +1720,6 @@ function MapSearch:CreateSearchFrame() globalSearchFrame:SetPoint("TOPRIGHT", WorldMapFrame.ScrollContainer, "BOTTOMRIGHT", 0, gYOff) end - local WHITE8x8 = "Interface\\BUTTONS\\WHITE8x8" ns.CreateSearchBorder(globalSearchFrame) if (EasyFind.db.resultsTheme or "Classic") == "Retail" then globalSearchFrame:SetBackdrop(nil) @@ -2116,6 +2109,9 @@ function MapSearch:CreateSearchFrame() navFrame:SetPropagateKeyboardInput(false) local function HandleNavKeyDown(key) + if key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" + or key == "LALT" or key == "RALT" then return end + local eb = activeSearchFrame and activeSearchFrame.editBox local dropdown = GetActiveDropdown() @@ -2139,9 +2135,6 @@ function MapSearch:CreateSearchFrame() end elseif key == "ESCAPE" then dropdown:Hide() - elseif key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" - or key == "LALT" or key == "RALT" then - -- stay in dropdown nav end return end @@ -2267,9 +2260,6 @@ function MapSearch:CreateSearchFrame() if MapSearch.StopKeyRepeat then MapSearch.StopKeyRepeat() end MapSearch:UpdateSelectionHighlight(true) end - elseif key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" - or key == "LALT" or key == "RALT" then - -- Modifier keys alone: stay in nav mode else ClearToolbarFocus() selectedResultIndex = 0 @@ -3027,14 +3017,12 @@ function MapSearch:GroupZonesByParent(zones) return zone.parentName or "" end - -- First pass: count how many zones share each full parent path - local pathCounts = {} + -- First pass: build path display and parent mapIDs local pathDisplay = {} local pathParentMapID = {} for _, zone in ipairs(zones) do local pathKey = getPathKey(zone) - pathCounts[pathKey] = (pathCounts[pathKey] or 0) + 1 if not pathDisplay[pathKey] then pathDisplay[pathKey] = getPathDisplay(zone) -- Get the last mapID in the path for navigation @@ -3053,9 +3041,7 @@ function MapSearch:GroupZonesByParent(zones) for _, zone in ipairs(zones) do local pathKey = getPathKey(zone) - if processedPaths[pathKey] then - -- Already processed this path group, skip - else + if not processedPaths[pathKey] then processedPaths[pathKey] = true -- Collect all zones with this same parent path @@ -3832,8 +3818,8 @@ function MapSearch:HighlightZoneOnMap(targetMapID, zoneName) if cL then local cX, cY = (cL + cR) / 2, (cT + cB) / 2 if cX > 0 and cX < 1 and cY > 0 and cY < 1 then - local resolved = GetMapInfoAtPosition(currentMapID, cX, cY) - if resolved and resolved.mapID == targetMapID then + local resolvedInfo = GetMapInfoAtPosition(currentMapID, cX, cY) + if resolvedInfo and resolvedInfo.mapID == targetMapID then DebugPrint("[EasyFind] CASE 1b: Target visible on current map (containing zone)") self.pendingZoneHighlight = targetMapID C_Timer.After(0.05, function() @@ -5174,7 +5160,6 @@ function MapSearch:GetPinInfo(pin) -- Area POIs (boats, zeppelins, portals, etc) - but NOT quests if pin.areaPoiInfo then name = pin.areaPoiInfo.name or pin.areaPoiInfo.description - pinType = "areapoi" local poiName = slower(name or "") local poiDesc = slower(pin.areaPoiInfo.description or "") @@ -5614,7 +5599,7 @@ function MapSearch:SearchPOIs(pois, query) local seen = reuseSearchSeen local duplicates = reuseSearchDuplicates - local matchedCategory, catScore, isExactCategoryMatch = self:GetCategoryMatch(query) + local matchedCategory = self:GetCategoryMatch(query) local relatedCategories = matchedCategory and self:GetRelatedCategories(matchedCategory) or {} -- First pass: name matches @@ -6149,7 +6134,6 @@ function MapSearch:SelectResult(data) -- Clear preview state so OnLeave doesn't undo the real selection self._previewing = nil self._savedPinState = nil - local sourceFrame = activeSearchFrame or searchFrame self._suppressTextChanged = true searchFrame.editBox:SetText("") searchFrame.editBox:ClearFocus() @@ -6521,7 +6505,6 @@ function MapSearch:HighlightPin(pin) return end - currentHighlightedPin = pin -- Convert UI-unit sizes to canvas units local userScale = EasyFind.db.iconScale or 0.8 @@ -6600,7 +6583,6 @@ function MapSearch:ClearHighlight() end end - currentHighlightedPin = nil end -- Resolve preview-able coordinates for a search result on the current map. diff --git a/Options.lua b/Options.lua index 61c6f32..b7f5460 100644 --- a/Options.lua +++ b/Options.lua @@ -1,4 +1,4 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local Options = {} ns.Options = Options @@ -10,7 +10,6 @@ local tonumber, tostring = Utils.tonumber, Utils.tostring local tinsert = Utils.tinsert local IsMouseButtonDown = IsMouseButtonDown -local GOLD_COLOR = ns.GOLD_COLOR local DEFAULT_OPACITY = ns.DEFAULT_OPACITY local TOOLTIP_BORDER = ns.TOOLTIP_BORDER local DARK_PANEL_BG = ns.DARK_PANEL_BG @@ -1067,7 +1066,6 @@ function Options:Initialize() .. "(Map Search) to open map zones in one click instead of highlighting them first." ) -- Keybind buttons - local KEYBIND_TOP = -8 -- offset below shortcutText (added dynamically) local KEYBIND_ROW_H = 28 local KEYBIND_BTN_W = 140 diff --git a/Rescaler.lua b/Rescaler.lua index 06f224b..d42d7eb 100644 --- a/Rescaler.lua +++ b/Rescaler.lua @@ -1,10 +1,10 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local Rescaler = {} ns.Rescaler = Rescaler local Utils = ns.Utils -local mmax, mmin, mfloor, mabs = Utils.mmax, Utils.mmin, Utils.mfloor, Utils.mabs +local mmax, mmin, mfloor = Utils.mmax, Utils.mmin, Utils.mfloor local tinsert = Utils.tinsert local GOLD_COLOR = ns.GOLD_COLOR @@ -13,8 +13,6 @@ local TOOLTIP_BORDER = ns.TOOLTIP_BORDER local MIN_WIDTH = 150 local MAX_WIDTH = 600 -local MIN_SCALE = 0.5 -local MAX_SCALE = 2.0 local HANDLE_SIZE = 10 local GLOW_OUTSET = 6 local PREVIEW_ROW_H = 26 @@ -68,18 +66,10 @@ end -- Helpers -local function ClampScale(v) - return mmax(MIN_SCALE, mmin(MAX_SCALE, v)) -end - local function ClampWidth(v) return mmax(MIN_WIDTH, mmin(MAX_WIDTH, v)) end -local function RoundTo(v, step) - return mfloor(v / step + 0.5) * step -end - local function AddResetButton(editBox, onConfirm) local btn = CreateFrame("Button", nil, editBox:GetParent()) btn:SetSize(editBox:GetWidth(), 16) @@ -663,11 +653,10 @@ function Rescaler:Enter(mode) activeMode = mode local searchBar, resultsFrame - local getBarWidth, setBarWidth, getBarScale, setBarScale - local getResultsWidth, setResultsWidth, getResultsScale, setResultsScale + local getBarWidth, setBarWidth + local getResultsWidth, setResultsWidth, getResultsScale if mode == "ui" then - local UI = ns.UI searchBar = _G["EasyFindSearchFrame"] resultsFrame = _G["EasyFindResultsFrame"] @@ -687,20 +676,7 @@ function Rescaler:Enter(mode) EasyFind.db.uiSearchWidth = w / 250 end - getBarScale = function() return EasyFind.db.uiSearchScale or 1.0 end - setBarScale = function(s) - s = ClampScale(s) - EasyFind.db.uiSearchScale = s - searchBar:SetScale(s) - end - getResultsScale = function() return EasyFind.db.uiResultsScale or 1.0 end - setResultsScale = function(s) - s = ClampScale(s) - EasyFind.db.uiResultsScale = s - if resultsFrame then resultsFrame:SetScale(s) end - if previewResults then previewResults:SetScale(s) end - end getResultsWidth = function() if resultsFrame then return resultsFrame:GetWidth() end @@ -713,8 +689,6 @@ function Rescaler:Enter(mode) end elseif mode == "map" then - local MapSearch = ns.MapSearch - -- Open the world map if not already visible (search bars are anchored to it) if not WorldMapFrame or not WorldMapFrame:IsShown() then ToggleWorldMap() @@ -737,22 +711,7 @@ function Rescaler:Enter(mode) if localBar then localBar:SetWidth(w) end end - getBarScale = function() return EasyFind.db.mapSearchScale or 1.0 end - setBarScale = function(s) - s = ClampScale(s) - EasyFind.db.mapSearchScale = s - searchBar:SetScale(s) - local localBar = _G["EasyFindMapSearchFrame"] - if localBar then localBar:SetScale(s) end - end - getResultsScale = function() return EasyFind.db.mapResultsScale or 1.0 end - setResultsScale = function(s) - s = ClampScale(s) - EasyFind.db.mapResultsScale = s - if resultsFrame then resultsFrame:SetScale(s) end - if previewResults then previewResults:SetScale(s) end - end getResultsWidth = function() if resultsFrame then return resultsFrame:GetWidth() end diff --git a/StaticLocations.lua b/StaticLocations.lua index 116cc44..439ded8 100644 --- a/StaticLocations.lua +++ b/StaticLocations.lua @@ -1,5 +1,5 @@ -- EasyFind Static Locations (auto-generated 2026-03-11 01:48) -local ADDON_NAME, ns = ... +local _, ns = ... ns.STATIC_LOCATIONS = { [84] = { -- Stormwind City { name = "Inn", category = "innkeeper", x = 0.6076649384171665, y = 0.7474117877548194, keywords = {"inn", "innkeeper", "hearth", "rest"} }, diff --git a/UI.lua b/UI.lua index 286b7d1..23a87ef 100644 --- a/UI.lua +++ b/UI.lua @@ -1,26 +1,21 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local UI = {} ns.UI = UI local Utils = ns.Utils local GetButtonText = Utils.GetButtonText -local SearchFrameTree = Utils.SearchFrameTree local SearchFrameTreeFuzzy = Utils.SearchFrameTreeFuzzy -local GetFrameByPath = Utils.GetFrameByPath local ClickButton = Utils.ClickButton -local DebugPrint = Utils.DebugPrint local select, ipairs, pairs = Utils.select, Utils.ipairs, Utils.pairs -local sfind, slower, sformat = Utils.sfind, Utils.slower, Utils.sformat -local tinsert, tsort, tconcat, tremove = Utils.tinsert, Utils.tsort, Utils.tconcat, Utils.tremove +local sfind, slower = Utils.sfind, Utils.slower +local tinsert, tconcat, tremove = Utils.tinsert, Utils.tconcat, Utils.tremove local mmin, mmax = Utils.mmin, Utils.mmax local GOLD_COLOR = ns.GOLD_COLOR -local YELLOW_HIGHLIGHT = ns.YELLOW_HIGHLIGHT local DEFAULT_OPACITY = ns.DEFAULT_OPACITY local TOOLTIP_BORDER = ns.TOOLTIP_BORDER local DARK_PANEL_BG = ns.DARK_PANEL_BG -local RESULT_ICON_SIZE = ns.RESULT_ICON_SIZE local CreateFrame = CreateFrame local C_Timer = C_Timer @@ -29,7 +24,6 @@ local GameTooltip = GameTooltip local GameTooltip_Hide = GameTooltip_Hide local IsShiftKeyDown = IsShiftKeyDown local GetCursorPosition = GetCursorPosition -local hooksecurefunc = hooksecurefunc local wipe = wipe local LIGHTNING_BOLT_TEX = "Interface\\AddOns\\EasyFind\\textures\\lightning-bolt" @@ -804,6 +798,9 @@ function UI:CreateSearchFrame() navFrame:SetPropagateKeyboardInput(false) local function HandleNavKeyDown(key) + if key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" + or key == "LALT" or key == "RALT" then return end + if key == "DOWN" then if IsControlKeyDown() then UI:JumpToEnd() @@ -892,9 +889,6 @@ function UI:CreateSearchFrame() if searchFrame.StopKeyRepeat then searchFrame.StopKeyRepeat() end UI:UpdateSelectionHighlight(true) end - elseif key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" - or key == "LALT" or key == "RALT" then - -- Modifier keys alone: stay in nav mode else ClearToolbarFocus() selectedIndex = 0 @@ -1064,7 +1058,6 @@ function UI:CreateUIFilterDropdown(toggleBtn, anchorFrame, searchEditBox) local ROW_HEIGHT = 20 local DROPDOWN_WIDTH = 207 local PADDING_TOP = 8 - local HEADER_HEIGHT = 19 local PADDING_BOTTOM = 8 local CHECK_SIZE = 16 @@ -1325,11 +1318,11 @@ function UI:CreateResultsFrame() local resizeTimer resultsFrame:SetScript("OnSizeChanged", function() - if not resultsFrame:IsShown() or not cachedHierarchical then return end + if not resultsFrame:IsShown() or not cachedHierarchical then return end -- luacheck: ignore 113 if resizeTimer then resizeTimer:Cancel() end resizeTimer = C_Timer.NewTimer(0.02, function() resizeTimer = nil - UI:ShowHierarchicalResults(cachedHierarchical, true) + UI:ShowHierarchicalResults(cachedHierarchical, true) -- luacheck: ignore 113 end) end) @@ -2230,18 +2223,12 @@ function UI:ShowHierarchicalResults(hierarchical, preserveScroll) -- If we're skipping children of a collapsed node, check depth if skipBelowDepth then - if d > skipBelowDepth then - -- Still inside collapsed subtree - skip - else - -- Back to same or higher depth - stop skipping + if d <= skipBelowDepth then skipBelowDepth = nil end end - -- Skip pinned items when pin header is collapsed - if skipPins and entry.isPinned then - -- skip this pinned entry - elseif not skipBelowDepth then + if not (skipPins and entry.isPinned) and not skipBelowDepth then if skipPins and not entry.isPinned then skipPins = false -- past the pin section end @@ -2565,9 +2552,7 @@ function UI:ShowHierarchicalResults(hierarchical, preserveScroll) resultRow.isPathNode = entry.isPathNode -- Store for tooltip text -- Position icon & text (non-tab, non-pin-header rows) - if entry.isPinHeader then - -- Pin header: text already positioned in header styling; hide icon - elseif not (theme.showHeaderTab and entry.isPathNode) then + if not entry.isPinHeader and not (theme.showHeaderTab and entry.isPathNode) then local indentPixels = depth * indPx resultRow.icon:ClearAllPoints() resultRow.icon:SetPoint("LEFT", resultRow, "LEFT", indentPixels, 0) @@ -2722,7 +2707,6 @@ function UI:ShowHierarchicalResults(hierarchical, preserveScroll) if data.toyItemID and iconFileID and GetItemCooldown then local startTime, duration = GetItemCooldown(data.toyItemID) if startTime and duration and duration > 0 then - local iconSize = theme.iconSize or 16 resultRow.iconCooldown:SetAllPoints(resultRow.icon) resultRow.iconCooldown:SetCooldown(startTime, duration) resultRow.iconCooldown:Show() @@ -4503,7 +4487,7 @@ function UI:FlashLabel(labelText) local flashCount = 0 local ticker ticker = C_Timer.NewTicker(0.3, function() - local ok, err = pcall(function() + local ok, _ = pcall(function() flashCount = flashCount + 1 if flashCount % 2 == 0 then label:SetTextColor(GOLD_COLOR[1], GOLD_COLOR[2], GOLD_COLOR[3]) @@ -4572,7 +4556,6 @@ function UI:UpdateFontSize() searchFrame:SetBackdropColor(0, 0, 0, alpha) end - local theme = GetActiveTheme() for i = 1, #resultButtons do local row = resultButtons[i] ScaleFont(row.text, theme.leafFont) diff --git a/Utils.lua b/Utils.lua index 084b9ca..7a8d325 100644 --- a/Utils.lua +++ b/Utils.lua @@ -1,4 +1,4 @@ -local ADDON_NAME, ns = ... +local _, ns = ... local Utils = {} ns.Utils = Utils @@ -9,7 +9,7 @@ local sfind, slower, ssub, sformat, smatch = string.find, string.lower, string.s local mmin, mmax, mabs, mpi, mceil, mfloor = math.min, math.max, math.abs, math.pi, math.ceil, math.floor local pcall, xpcall, tostring, tonumber = pcall, xpcall, tostring, tonumber local debugstack = debugstack -local GetTime, CreateFrame = GetTime, CreateFrame +local CreateFrame = CreateFrame local function ErrorHandler(err) return tostring(err) .. "\n" .. debugstack(2)