atom / fuzzy-finder

Find and open files quickly
MIT License
274 stars 138 forks source link

Fuzzy Finder resolves paths with symlinks when opening files #351

Closed b-fuze closed 5 years ago

b-fuze commented 5 years ago

Prerequisites

Description

Fuzzy finder resolves file paths with symlinks, it changes for example the project path from

/home/b-fuse/Projects/git/atom/atom

To

/media/b-fuse/22fb982d-3d59-4389-817d-a482aef0ec5a/home/b-fuse/Projects/git/atom/atom

So when it opens files plugins like ide-typescript thinks the file's in another folder (which is pretty much the case path-wise)

Steps to Reproduce

  1. Open a folder that is a symlink
  2. Ctrl + T to locate a file
  3. Open it

Desired behavior: I'd rather it not resolve the symlink.

Actual behavior: It resolve symlink paths with fs.realpathSync(path) on https://github.com/atom/fuzzy-finder/blob/f096a3e1faea35573d1619e410496031e9cccce4/lib/path-loader.js#L12

Solutions

A simple solution is to simply remove the .map(...) altogether... But I don't know what that impacts exactly (I only work on Linux machines)

This could probably also work

const projectPaths = atom.project.getPaths().map((path) => followSymlinks ? fs.realpathSync(path) : path)

But that's probably a bad solution.

Versions

fuzzy-finder: 1.8.2 OS: Ubuntu 18.04

lee-dohm commented 5 years ago

Following that line of code back to before it was decaffeinated brings us to this PR https://github.com/atom/fuzzy-finder/pull/178. Which resolved a long-standing issue https://github.com/atom/fuzzy-finder/issues/87. So we won't want to revert that change.

I'm not sure why resolving the project path, in other words the root of the repository, would cause a problem for ide-typescript though?

b-fuze commented 5 years ago

@lee-dohm since Atom by default doesn't resolve the workspace/project? path it causes for example ide-typescript to ignore .ts files opened because it thinks they're not in the project dir.

This is the project folder

/home/b-fuse/Projects/git/atom/atom

But when I Ctrl + T to another file it opens it in

/media/b-fuse/22fb982d-3d59-4389-817d-a482aef0ec5a/home/b-fuse/Projects/git/atom/atom

And naturally ide-typescript assumes that it's a different folder so it doesn't check the file...

Here's an example, with the same file I opened it with Ctrl + T on the left pane, and opened it from the file tree on the right... (You can see the paths in the tabs)

Firstly ide-typescript thinks the file isn't located in the project dir so it doesn't error for the left pane, and secondly Atom assumes I'm editing two different files (the buffers aren't linked, which makes sense as they're different paths) image

I want Fuzzy Finder to speed up my workflow but this is preventing me from using it.

lee-dohm commented 5 years ago

The problem you describe of ide-typescript not realizing the file is within the project is something that has been mentioned before. Unfortunately, there is no good solution other than expecting packages to manage their own semantics around whether to resolve symlinks or not. Atom has to resolve the symlinks or else Atom won't behave as people expect.