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

allow fuzzy completion #332

Merged
merged 3 commits into from
May 14, 2022
Merged

allow fuzzy completion #332

merged 3 commits into from
May 14, 2022

Conversation

ananthakumaran
Copy link
Owner

No description provided.

@felzix
Copy link

felzix commented Oct 25, 2021

Anything I can do to help get this merged in?

Also, any idea if this change would make company-fuzzy-mode work? Right now it just returns nothing from company-tide.

@ananthakumaran
Copy link
Owner Author

ananthakumaran commented Oct 26, 2021

@felzix I rebased the commits. You can try it out and let us know if it works as expected. To enable the feature you need to have (setq tide-completion-fuzzy t)

Also, any idea if this change would make company-fuzzy-mode work? Right now it just returns nothing from company-tide.

I think fuzzy completion on tide is probably a prerequisite (I don't see how the plugin can get the results otherwise).

@kijowski
Copy link
Contributor

Hi @ananthakumaran. I've taken this feature for a test ride and it works fine with one small caveat - setting (setq tide-completion-fuzzy t) ignores tide-completion-ignore-case value and makes completion case-insensitive by default (at least in my setup). This is because string-match-p case sensitivity is controlled by case-fold-search. It can be easily fixed by following patch:

 @@ -1669,7 +1669,8 @@ This function is used for the basic completions sorting."
   (-filter (lambda (completion)
              (and
               (if tide-completion-fuzzy
-                  (string-match-p (regexp-quote prefix) (plist-get completion :name))
+                  (let ((case-fold-search tide-completion-ignore-case)) 
+                    (string-match-p (regexp-quote prefix) (plist-get completion :name)))
                 (string-prefix-p prefix (plist-get completion :name) tide-completion-ignore-case))
               (or (not tide-filter-out-warning-completions)
                   (not (equal (plist-get completion :kind) "warning")))))
@@ -1818,7 +1819,8 @@ This function is used for the basic completions sorting."
      (let* ((completion (get-text-property 0 'completion arg))
             (prefix (get-text-property 0 'prefix arg))
             (start (if tide-completion-fuzzy
-                       (string-match-p (regexp-quote prefix) (plist-get completion :name))
+                       (let ((case-fold-search tide-completion-ignore-case)) 
+                         (string-match-p (regexp-quote prefix) (plist-get completion :name)))
                      0)))
        `((,start . ,(+ start (length prefix))))))
     ((annotation) (tide-completion-annotation arg))

Other than that I think that fuzzy matching is working as intended. Please let me know if you want me to check some specific use case.

@ananthakumaran
Copy link
Owner Author

Thanks for testing the PR and your patch. It looks like I missed the case flag. I will merge soon

@ananthakumaran ananthakumaran merged commit 96bfc5d into master May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants