flexdesk 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flexdesk",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "A tiling window manager and widget set for desktop-class web applications. Zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -875,15 +875,27 @@ function _match(text, query) {
875
875
  const sub = t.indexOf(q);
876
876
  if (sub >= 0) return { s: 60, hits: span(sub, q.length) };
877
877
 
878
+ // TIGHT OR NOT AT ALL. A subsequence is for an abbreviation — "cstmr",
879
+ // "ord ln" — not for any label that happens to hold the letters in order:
880
+ // with a loose bound, "cour" found "Scroll up to: 1,000 rows" and "new"
881
+ // found "Below the pane", and those rows buried the ones meant. So the
882
+ // match starts at a word start, a jump that lands on a word start is free
883
+ // (that is what an abbreviation is), and every other skipped letter counts:
884
+ // together they may be half the query, no more.
878
885
  const flat = q.replace(/\s+/g, '');
886
+ const startsWord = (i) => i === 0 || _WORD_BREAK.test(t[i - 1]);
879
887
  const hits = [];
880
888
  let j = 0;
881
889
  for (let i = 0; i < t.length && j < flat.length; i++) {
882
890
  if (t[i] === flat[j]) { hits.push(i); j++; }
883
891
  }
884
- if (j < flat.length) return null;
885
- const spread = hits[hits.length - 1] - hits[0] + 1 - flat.length;
886
- if (spread > 3 * flat.length + 6) return null; // letters strewn across a long label
892
+ if (j < flat.length || !startsWord(hits[0])) return null;
893
+ let spread = 0;
894
+ for (let k = 1; k < hits.length; k++) {
895
+ const gap = hits[k] - hits[k - 1] - 1;
896
+ if (gap > 0 && !startsWord(hits[k])) spread += gap;
897
+ }
898
+ if (spread > Math.floor(flat.length / 2)) return null;
887
899
  return { s: Math.max(1, 30 - spread), hits };
888
900
  }
889
901