Repository navigation
Initial paths shouldn't be normalized on save and restore (could contain uris) - #6813
Conversation
|
I think I would rather avoid normalizing paths if they are not local: for pathToOpen, i in pathsToOpen
if fs.existsSync(pathToOpen)
pathsToOpen[i] = fs.normalize(pathToOpen)I don't think we should omit any project paths from hash, because then you might do |
|
@maxbrunsfeld agree and changed the code accordingly. |
There was a problem hiding this comment.
I think this should be moved below the return {pathToOpen} unless pathToOpen check since url.parse blows up with a null or undefined pathToOpen
There was a problem hiding this comment.
done, and looks cleaner as one-liner
|
Would be great cover these changes with tests before merging this. |
|
@kevinsawicki added relevant tests in |
|
c1a4391 to
3bb4345
Compare
bf62022 to
6a0b6d6
Compare
|
@kevinsawicki I added an integration test, but all integration tests are failing for me either ways - which got me a bit frustrated. I hope the travis CI gets it or if you could help run the integration test to verify it works. |
6a0b6d6 to
e7064bf
Compare
|
@mostafaeweda I would actually say don't worry about adding an integration test for this. If I understand correctly, the purpose of your change is to fix problems that occur when using packages that provide custom Currently though, it does break existing integration tests. This is the output on my machine, running these tests: I can help you with debugging these failures. You said all integration specs fail when you run them on your machine? Can you share some of the output? |
|
I was getting different kind of outputs from the integration tests, sometimes, I get the expected stuff failures, and other times, chrome driver timeout & most of the time: chrome driver io already in use error. Fortunately, @maxbrunsfeld helped me debug this & killing the chromedriver stale processes. |
There was a problem hiding this comment.
I'm thinking maybe we should just remove this test, unless you think it's testing something important. What exactly is it testing?
There was a problem hiding this comment.
When I saw this PR included changes to how atom-application.coffee behaves I suggested adding an integration test since those are the only tests for that code currently.
There was a problem hiding this comment.
This is testing that the remote project path survives as a uri, without any other code normalizing it on the way.
There was a problem hiding this comment.
I see your point, but I don't know if the asserted behavior makes sense. It's asserting that the tree view's "root directory" is remote://something, even though there is no such directory, and there is no directory provider for remote URLs. It seems like we've gotten the editor into a weird state here.
There was a problem hiding this comment.
That weird state was already the case, and it was handled by us later when our package is activated to replace the root directory with its remote version.
All what this PR guarantees is that the path survives normalization, but doesn't fix the fact that Atom core initializes and deserializes state before the third party packages get a say in how that should happen.
However, I'd be happy to help in a following PR that does something like what @bolinfest suggested before:
Either:
When serializing the project state, include which directory provider (by names) created this directory and when reloading the state, wait for that specific directory provider to register and create the directories at that time
OR:
Add a function to directory providers:
handlePath(path: string): booleanwhere that would be in default-directory-provider.coffee:
handlePath(directoryPath) ->
fs.existsSync(directoryPath) or fs.existsSync(path.dirname(directoryPath))and in remote directory provider:
handlePath(directoryPath) ->
directoryPath.startsWith('remote://')There was a problem hiding this comment.
Atom core initializes and deserializes state before the third party packages get a say in how that should happen.
I see. You're right; this test seems useful 👍.
|
It's too bad that we do path normalization in so many different places, so that you had to change this in so many places. I'd really like to refactor the code such that the path stays un-normalized for as long as possible, giving the For now, though, I think this is the right thing to do. Except for my question about the integration test you added, this looks good to me. |
Initial paths shouldn't be normalized on save and restore (could contain uris)
Including url-style paths like
remote://host:port/some/pathin theinitialPathscauses state loss issues, because the hash creation in: https://github.com/atom/atom/blob/master/src/atom.coffee#L93 creates a key that's different from the key got when restoring the state, because theinitialPathsare normalized and not existing (see: https://github.com/atom/atom/blob/master/src/browser/atom-application.coffee#L372).So, when the initialPaths contain a url, the state is never restored
This diff makes sure that project paths and
initialPathsaren't normalized when not local paths@bolinfest @maxbrunsfeld @benogle