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

Editors - pathsToEditors should ignore folders #136359

Merged
merged 4 commits into from
Nov 4, 2021
Merged

Conversation

lszomoru
Copy link
Member

@lszomoru lszomoru commented Nov 3, 2021

Ignore folders when creating the editor inputs.

@lszomoru lszomoru added this to the November 2021 milestone Nov 3, 2021
@lszomoru lszomoru self-assigned this Nov 3, 2021
src/vs/workbench/common/editor.ts Outdated Show resolved Hide resolved
@lszomoru lszomoru requested a review from bpasero November 4, 2021 08:31
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit worried that doing the stat everytime now, even when we now the file exists could slow down startup. This is on the critical path of the perf machine, so we should probably avoid the file service use unless we need it.

@lszomoru
Copy link
Member Author

lszomoru commented Nov 4, 2021

@bpasero, I think that is a fair concern, though what other option do we have to detect that the path is a folder without making a stat call? Could we enhance the editor service in order to handle this scenario? Happy to chat about our options. Thanks!

@bpasero
Copy link
Member

bpasero commented Nov 4, 2021

Whoever is setting the exists property to true could maybe rather indicate the type of the path? We seem to be doing a stat call somewhere else to figure this out so we can make it provide the needed information.

@lszomoru
Copy link
Member Author

lszomoru commented Nov 4, 2021

@bpasero, what about adding file/folder information to IPathData?
By doing so, we would have to call stat if that information is missing.

@bpasero
Copy link
Member

bpasero commented Nov 4, 2021

Yeah, something like that is what I had in mind. It would probably be sufficient to just indicate if its a file or folder.

@lszomoru lszomoru requested a review from bpasero November 4, 2021 12:17
@joaomoreno
Copy link
Member

joaomoreno commented Nov 4, 2021

I am a bit worried that doing the stat everytime now, even when we now the file exists could slow down startup. This is on the critical path of the perf machine, so we should probably avoid the file service use unless we need it.

Perf-wise, what's the difference between fileService.exists and fileService.resolve? In a Node.JS based file system provider, for example, those two are the same: exists is built on top of resolve. And in fact...

https://github.com/microsoft/vscode/blob/bccd9b904b24c4b778753c93669c5f21dc1e1c7d/src/vs/platform/files/common/fileService.ts/#L297-L308

The code already calls fileService.exist. Switching that with fileService.resolve won't make it any slower.

@lszomoru
Copy link
Member Author

lszomoru commented Nov 4, 2021

@joaomoreno, I believe that the concern was that originally fileService.exists was only called in case that path.exists was not set. To understand whether the path is a file/folder we would have had to call fileService.resolve every single time independent whether path.exists was set or not. The latest iteration of the PR, only calls fileService.resolve if path.exists or path.isFile is not set.

@joaomoreno
Copy link
Member

To understand whether the path is a file/folder we would have had to call fileService.resolve every single time independent whether path.exists was set or not.

For your intended purposes, you're always passing path.exists: true, so I'd keep the current semantics: if path.exists: true then resolve is called, otherwise we just assume it exists and is a file and go ahead with it.

@lszomoru
Copy link
Member Author

lszomoru commented Nov 4, 2021

As far as I can tell, I could be wrong, path.exists is not being set when opening a file through vscode.dev.

@joaomoreno
Copy link
Member

I see now. Sad!

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lszomoru please see my 💄 change that I just pushed. I only changed to have the FileType instead of a boolean.

@lszomoru lszomoru merged commit e31a18e into main Nov 4, 2021
@lszomoru lszomoru deleted the lszomoru/pathsToEditors branch November 4, 2021 20:03
lszomoru added a commit that referenced this pull request Nov 10, 2021
lszomoru added a commit that referenced this pull request Nov 10, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants