Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use filter-exact-matches in much more places. #2868

Merged
merged 2 commits into from
Mar 24, 2023
Merged

Conversation

aartaka
Copy link
Contributor

@aartaka aartaka commented Mar 21, 2023

This makes most of our sources more exact in matching the input. This is important for sources with URLs, medium-to-huge quantities of text, or many-attributes sources.

Please, someone, just look at this change and accept that our sources are more exact and useful now :)

Closes #2792.

Discussion

  • Should I add test for that?
  • Also note that nyxt/gi-gtk tests fail even on master :P

Checklist:

Everything in this checklist is required for each PR. Please do not approve a PR that does not have all of these items.

  • Git hygiene:
    • I have pulled from master before submitting this PR
    • There are no merge conflicts.
  • I've added the new dependencies as:
    • ASDF dependencies,
    • Git submodules,
      cd /path/to/nyxt/checkout
      git submodule add https://gitlab.common-lisp.net/nyxt/py-configparser _build/py-configparser
    • and Guix dependencies.
  • My code follows the style guidelines for Common Lisp code. See:
  • I have performed a self-review of my own code.
  • My code has been reviewed by at least one peer. (The peer review to approve a PR counts. The reviewer must download and test the code.)
  • Documentation:
    • All my code has docstrings and :documentations written in the aforementioned style. (It's OK to skip the docstring for really trivial parts.)
    • I have updated the existing documentation to match my changes.
    • I have commented my code in hard-to-understand areas.
    • I have updated the changelog.lisp with my changes if it's anything user-facing (new features, important bug fix, compatibility breakage).
    • I have added a migration.lisp entry for all compatibility-breaking changes.
    • (If this changes something about the features showcased on Nyxt website) I have these changes described in the new/existing article at Nyxt website or will notify one of maintainters to do so.
  • Compilation and tests:
    • My changes generate no new warnings.
    • I have added tests that prove my fix is effective or that my feature works. (If possible.)
    • I ran the tests locally ((asdf:test-system :nyxt) and (asdf:test-system :nyxt/gi-gtk)) and they pass.

@aartaka aartaka requested a review from aadcg March 21, 2023 18:14
source/changelog.lisp Outdated Show resolved Hide resolved
@@ -28,7 +28,8 @@
(mapc #'reopen-dead-buffer buffer-list)
(set-current-buffer (or (first (prompter:marks (current-source)))
(current-suggestion-value (current-prompt-buffer)))))
(lambda-mapped-command reopen-dead-buffer)))))
(lambda-mapped-command reopen-dead-buffer)))
(prompter:filter-preprocessor #'prompter:filter-exact-matches)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why for buffers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because buffers have URLs in them, and because buffer-source is used in set-url to match against buffers. In the latter case, it's extremely important to filter aggressively, so that the source disappears the very moment it becomes irrelevant.

@@ -279,6 +284,7 @@ Otherwise go forward to the only child."
(define-class history-all-source (prompter:source)
((prompter:name "All history URLs")
(buffer :initarg :buffer :accessor buffer :initform nil)
(prompter:filter-preprocessor #'prompter:filter-exact-matches)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's not just URLs, it's also titles, so this may be too restrictive.
Same for all history sources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then wait, filter-exact-matches matches against every word separately, so titles are fine too: if there's a word from a title and a word from a URL, the suggestion is still matched, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, but fuzzy-matching on titles is desirable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still say that most of people search things by space-separated chunks of text, so fuzzy matching that works backwards or matches every single letter is not as useful as matching clearly delineated word-like sequences.

@aartaka aartaka force-pushed the filter-aggressively branch from a9d6cb1 to 78bd832 Compare March 22, 2023 11:01
@aadcg
Copy link
Member

aadcg commented Mar 23, 2023

I'm taking a look at this later today or tomorrow. Thanks!

@aadcg
Copy link
Member

aadcg commented Mar 23, 2023

I believe @Ambrevar already did a good review.

This seems to address issue #2792, and probably closes it too. I wonder if the default for prompter:filter-preprocessor shouldn't be changed, but I didn't think about it enough.

Feel free to proceed as you find most adequate!

@aartaka
Copy link
Contributor Author

aartaka commented Mar 24, 2023

This seems to address issue #2792, and probably closes it too.

Yes, I just was unable to find the issue xD

I wonder if the default for prompter:filter-preprocessor shouldn't be changed, but I didn't think about it enough.

I lean to that too, because filter-exact-matches is probably the most intuitive matching algo we have. But I'll leave that for @Ambrevar to decide, given that libraries/prompter is to be someday abstracted out, and that will prompt (pun not intended) for all the necessary architectural redesigns.

aartaka added 2 commits March 24, 2023 14:16
This way, sources disappear when having no matches, or narrow down to the useful
suggestions really fast. This is particularly important when dealing with lots
of noisy data, like URLs, colors, lots of text entries.

The default preprocessor, delete-inexact-matches, is insufficient, as it matches
all the suggestion against any substring of input, which almost always passes
most elements through.
@aartaka aartaka force-pushed the filter-aggressively branch from 78bd832 to b1c946e Compare March 24, 2023 10:16
@aartaka aartaka merged commit 58face9 into master Mar 24, 2023
@aartaka aartaka deleted the filter-aggressively branch March 24, 2023 10:16
aadcg referenced this pull request Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

fuzzy-match behavior when input doesn't match any suggestions
3 participants