Skip to content

[BC] Detection of "root directory" create BC breaks and can't be disabled #985

Closed

Description

@camilledejoye

let request = { "action": a:action, "parameters": a:arguments }
let l:workspaceDir = s:searchDirectoryUpwardForRootPatterns(
\ fnamemodify(phpactor#_path(), ':h'),
\ g:phpactorProjectRootPatterns,
\ g:phpactorInitialCwd
\)

That's bad!
I didn't looked too much as #923 because I didn't saw the point, not that there is none but I work with noautochdir and my Vim always start at the root of my project.

But I just updated my work environment to test LSP in real conditions, since yesterday I can't complete classes, import them, etc

We need to be a bit more careful about BC breaks I guess, on develop it's kind of acceptable.
But this will be a MASSIVE change IMO that needs to be clearly mentioned in the changelog.

Even better would be to make it configurable, I wonder if we could look at the autochdir option and disable that improvement if the option is off.
My problem with that right know, is that phpactor behave as if I was in a directory that I'm actually not in!

The worse thing is that I can't actually disable the auto-detection !!!
I need to cheet and add let g:phpactorProjectRootPatterns = [] to my vimrc, but it's really a hack because I don't need anything to be done since the directory will never change.
Now on each RPC request made, the vim plugin will loop over all parent directories of my pwd until it reaches my home directory and then fallback to the value I want from the start.

Activity

  1. dantleech commented on Apr 28, 2020

    @dantleech
    Collaborator

    Yes, I did that too. We should set to [] by default for now (or revert, but that might cause conflicts)
    It would be replaced by #959 @przepompownia

  2. camilledejoye commented on Apr 28, 2020

    @camilledejoye
    ContributorAuthor

    OK I will check it again then, make sure that we can disable it entirely and not just tweak the all thing.
    Personally I see this feature as optional, if you want auto-detection activate it.
    Otherwise we just use the vim pwd, I guess any plugins that deal with projects inside vim (there is multiple already that do all that) will change the current directory per buffer.
    So we should default the current directory, allowing other plugins to do their job and provide the correct path if needed.
    And only on last resort, because of the user will we offer a detection system.

    I don't know if that make sense or not...

  3. dantleech commented on Apr 28, 2020

    @dantleech
    Collaborator

    The problem is that plugins change the CWD and people expect Phpactor to work in the new CWD, but as the CWD can be in a random directory and not necessarily the project root, Phpactor would need to detect the project root.

    I think @przepompownia 's new PR will only offer to change it's CWD if it is on a different branch of the filesystem, so then you wouldn't be prompted (and the CWD wouldn't be detected) until you open a new project.

  4. przepompownia commented on Apr 28, 2020

    @przepompownia
    Contributor

    Currently the new PR allows working workspace root detection as before #923 (with let g:phpactorNoninteractiveProjectResolvers = [] in user settings tht can be chaned as the default). It also allows disable user prompt (by default).

    Lack of my free time slows down making fixes, refactor and responding to comments. This PR still does not uses the result (i.e. it does not override l:workspaceDir by b:phpactorProject.primaryRootPath).

    Shortly: determining root by CWD and by root markers are not usable in some cases. PR #959 tries to resolve it.

  5. przepompownia commented on Apr 28, 2020

    @przepompownia
    Contributor

    Now on each RPC request made, the vim plugin will loop over all parent directories of my pwd until it reaches my home directory and then fallback to the value I want from the start.

    It is bad, you are right. With #959 after using b:phpactorProject.primaryRootPath there would no recalculation the root path with each RPC request.

  6. przepompownia commented on Apr 28, 2020

    @przepompownia
    Contributor

    In cc700e9 recalculation with s:searchDirectoryUpwardForRootPatterns() was dropped in favor to use b:phpactorProject.primaryRootPath.

  7. dantleech commented on May 3, 2020

    @dantleech
    Collaborator

    This feature has now been removed from develop, but let's push it into the next release :) #1001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions