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

Fix lsp--suggest-project-root always suggesting something #3972

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ia0
Copy link
Contributor

@ia0 ia0 commented Feb 25, 2023

This reverts #2112.

The intent of lsp--suggest-project-root is not to always return non-nil but instead return nil when no good suggestion is found and let the caller decide what to do in such case. This can be seen in 2 different ways:

  1. All calls except in lsp--calculate-root (see 2 below) use the following form which demonstrates that the function should sometimes return nil.

    (or (lsp--suggest-project-root) default-directory)
    
  2. We find the following snippet in lsp--calculate-root which demonstrates that the function should sometimes return nil (otherwise unless lsp-auto-guess-root could be removed since always true).

    (or
     (when lsp-auto-guess-root
       (lsp--suggest-project-root))
     (lsp-find-session-folder session file-name)
     (unless lsp-auto-guess-root
    

This reverts emacs-lsp#2112.

The intent of `lsp--suggest-project-root` is not to always return non-nil but
instead return nil when no good suggestion is found and let the caller decide
what to do in such case. This can be seen in 2 different ways:

1. All calls except in `lsp--calculate-root` (see 2 below) use the following
form which demonstrates that the function should sometimes return nil.

    ```
    (or (lsp--suggest-project-root) default-directory)
    ```

2. We find the following snippet in `lsp--calculate-root` which demonstrates
that the function should sometimes return nil (otherwise `unless
lsp-auto-guess-root` could be removed since always true).

    ```
    (or
     (when lsp-auto-guess-root
       (lsp--suggest-project-root))
     (lsp-find-session-folder session file-name)
     (unless lsp-auto-guess-root
    ```
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.

1 participant