Skip to content

Commit

Permalink
Fix FastSearch ordering (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot authored Nov 20, 2023
1 parent 37c7550 commit ea2ece2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Tweaks/UiAdjustment/FastSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Utility.Signatures;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using FFXIVClientStructs.Interop.Attributes;
using Dalamud.Memory;
using LuminaAddon = Lumina.Excel.GeneratedSheets.Addon;
Expand All @@ -27,6 +25,7 @@ namespace SimpleTweaksPlugin.Tweaks.UiAdjustment;
[TweakAuthor("Asriel")]
[TweakAutoConfig]
[TweakReleaseVersion("1.9.2.0")]
[Changelog(UnreleasedVersion, "Fix random ordering (results are now always in the same order)")]
public unsafe class FastSearch : UiAdjustments.SubTweak {
public class FastSearchConfig : TweakConfig {
[TweakConfigOption("Use Fuzzy Search")]
Expand Down Expand Up @@ -196,6 +195,7 @@ private void RecipeSearch(string input, StdVector<uint>* output) {
.Select(i => (Item: i, Score: matcher.Matches(i.ItemResult.Value!.Name.ToDalamudString().ToString().ToLowerInvariant())))
.Where(t => t.Score > 0)
.OrderByDescending(t => t.Score)
.ThenBy(t => t.Item.RowId)
.Select(t => t.Item.RowId);

foreach (var v in query)
Expand All @@ -211,6 +211,7 @@ private void ItemSearch(string input, AgentItemSearch2* agent) {
.Select(i => (Item: i, Score: matcher.Matches(i.Name.ToDalamudString().ToString().ToLowerInvariant())))
.Where(t => t.Score > 0)
.OrderByDescending(t => t.Score)
.ThenBy(t => t.Item.RowId)
.Select(t => t.Item.RowId);
foreach (var item in query) {
agent->ItemBuffer[agent->ItemCount++] = item;
Expand Down

0 comments on commit ea2ece2

Please sign in to comment.