Compare commits
No commits in common. "8fcd2366f2e0a9c7b8c1ac45dc6652542106ea1a" and "f94358b38118db4b54a3289655d6730a32096cf4" have entirely different histories.
8fcd2366f2
...
f94358b381
File diff suppressed because it is too large
Load Diff
|
@ -19,11 +19,12 @@ export class GViewProvider implements vscode.WebviewViewProvider {
|
|||
) {
|
||||
webviewView.webview.options = { enableScripts: true };
|
||||
this._view = webviewView;
|
||||
console.log("resolveWebviewView:------------");
|
||||
webviewView.webview.html = this.generateHtml(webviewView);
|
||||
|
||||
// 添加事件监听器
|
||||
webviewView.webview.onDidReceiveMessage(
|
||||
(message: { command: any; text: any; filePath: any; hash: any; }) => {
|
||||
(message) => {
|
||||
switch (message.command) {
|
||||
case "filterCommits":
|
||||
const filterText = message.text;
|
||||
|
@ -32,6 +33,9 @@ export class GViewProvider implements vscode.WebviewViewProvider {
|
|||
case "openFile":
|
||||
const filePath = message.filePath;
|
||||
const commit = message.hash;
|
||||
// should open git change for file and commit
|
||||
// vscode.commands.executeCommand('git.showCommit',commit)
|
||||
// this.openFileInCommit(commit, filePath);
|
||||
this.openDiff(commit, filePath);
|
||||
return;
|
||||
}
|
||||
|
@ -49,6 +53,19 @@ private makeUri(repoPath:string, filePath:string, commit:string) {
|
|||
}
|
||||
return fUri.with({ scheme: 'git',path:fUri.path, query: JSON.stringify(params) });
|
||||
}
|
||||
private openFileInCommit(commitHash: any, filePath: any) {
|
||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||
if(!workspaceFolder){
|
||||
throw new Error('Please open a workspace folder first');
|
||||
}
|
||||
const repoPath = workspaceFolder.replace(/\\/g, '/')
|
||||
.replace(/'/g, "'")
|
||||
.replace(/ /g, " ");
|
||||
const fileUri = vscode.Uri.parse(`git://${repoPath}?${commitHash}#${filePath}`);
|
||||
vscode.workspace.openTextDocument(fileUri).then(doc => {
|
||||
vscode.window.showTextDocument(doc);
|
||||
})
|
||||
}
|
||||
|
||||
private async openDiff(commitId: string, filePath: string) {
|
||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||
|
@ -79,6 +96,10 @@ private async openDiff(commitId: string, filePath: string) {
|
|||
|
||||
const previousUri = this.makeUri(sanitizedWorkPath, sanitizedFilePath, encodedPrevCommit);
|
||||
|
||||
// 调试输出
|
||||
console.log('Current URI:', currentUri.toString());
|
||||
console.log('Previous URI:', previousUri.toString());
|
||||
|
||||
await vscode.commands.executeCommand(
|
||||
"vscode.diff",
|
||||
previousUri,
|
||||
|
|
Loading…
Reference in New Issue