I am trying to create a version control extension in vscode. I tried to take a look at the git implementation in vscode. The confusing part is the diff file. The source code for the git extension uses vscode.diff to view file vscode.diff . To get the uri source file, a new uri is created by changing the scheme modified uri file. How it works?
eg,
In https://github.com/Microsoft/vscode/blob/master/extensions/git/src/commands.ts , getRightResource method, toGitUri is called from the uri of the file. toGitUri is executed as follows:
export function toGitUri(uri: Uri, ref: string, replaceFileExtension = false): Uri { return uri.with({ scheme: 'git', path: replaceFileExtension ? `${uri.path}.git` : uri.path, query: JSON.stringify({ path: uri.fsPath, ref }) }); }
Here toGitUri just changes the file scheme from file to git with the request. This uri then provided by vscode.diff along with the original uri file to show diff git. How does toGitUri work?
thanks and welcome
Satish V
version-control visual-studio-code vscode-extensions
Sathish v
source share