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

save/load history where file open from command line #24

Closed
MarekLew opened this issue Oct 13, 2017 · 8 comments
Closed

save/load history where file open from command line #24

MarekLew opened this issue Oct 13, 2017 · 8 comments

Comments

@MarekLew
Copy link

When file is open from the command line "code -r {path to file}" then history not saved and not loaded,
even if the file is in the current directory. I must close file and reopen from explorer panel (VSC), then history loaded and created.

extension: 1.6.0
vsc: 1.17.1
system: windows 10 Home 10 version 10.0.15063 compile 15063

The bug start exist befor 1.6.0, 1.5.2 mayby or in vsc 1.17 (I do not know when).

@MarekLew MarekLew changed the title save history where file open from command line save/load history where file open from command line Oct 13, 2017
@MarekLew
Copy link
Author

It's VSC bug vscode.workspace.getWorkspaceFolder(file) don't return workspace folder when file open from command line. microsoft/vscode#36221

@zabel-xyz
Copy link
Owner

zabel-xyz commented Oct 13, 2017

I noticed this bug too, but I have not said that to vscode yet.
Thanks for the bug report to the vscode team ...

@MarekLew
Copy link
Author

You have commentet block in HistorySettings.get(file history.settings.ts) when I uncoment and modyfi

        if (!folder){
            folder = vscode.workspace.rootPath ? vscode.Uri.file(vscode.workspace.rootPath) : undefined;
            if (folder) {
                // if file is not a child of workspace => undefined
                const relativeFile = vscode.workspace.asRelativePath(file.fsPath);
                if (relativeFile === file.fsPath.replace(/\\/g, '/'))
                    folder = undefined;
            }
        }

then at this moment work fine.

@zabel-xyz
Copy link
Owner

I commented this code because vscode.workspace.rootPath is now deprecated, according to https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs
I think is a bug in Multi Root Workspace APIs....

@zabel-xyz zabel-xyz added the bug label Oct 13, 2017
@MarekLew
Copy link
Author

MarekLew commented Oct 16, 2017

It's probably don't fixed before vcs 1.18.0 because this bug do not exist in 1.18.0-insider Version.

@MarekLew
Copy link
Author

MarekLew commented Oct 17, 2017

vscode.workspace.getWorkspaceFolder(file) it's not stable. Use workspaceFolders[i] as rootPath.

@zabel-xyz
Copy link
Owner

I'll publish a version with this fix (this will resolve this issue, waiting version 1.18.0)

    let folder;
      const wsFolder = vscode.workspace.getWorkspaceFolder(file);
      if (wsFolder)
          folder = wsFolder.uri;
      // temporary code to resolve bug https://github.com/Microsoft/vscode/issues/36221
      else if (file && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length === 1) {
          if (file.fsPath.includes(vscode.workspace.workspaceFolders[0].uri.fsPath))
              folder = vscode.workspace.workspaceFolders[0].uri;
      }

@zabel-xyz
Copy link
Owner

Publish a temporary workaround in version 1.6.1

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

No branches or pull requests

2 participants