public bool Match(InputKeyIndex other, bool partial = false) { if (partial) { var otherSpan = new Span <int>(other.index, 0, this.index.Length); return(this.index.Length >= other.index.Length && otherSpan.StartsWith(this.index)); } else { return(this.index.Length == other.index.Length && Enumerable.SequenceEqual(this.index, other.index)); } }
public InputKeyMatch FuzzyMatch(InputKeyIndex other, int fuzzy = 0) { if (this.Match(other)) { return(InputKeyMatch.FullMatch); } // We don't want a lot of shorter versions that might match. // This will just flood our results otherwise. if (this.index.Length < other.index.Length) { return(InputKeyMatch.NoMatch); } var startWithResult = FuzzyHelper.StartWith(this.index, other.index); if (startWithResult <= fuzzy) { return(InputKeyMatch.PartialMatch); } return(InputKeyMatch.NoMatch); }