Skip to content

Commit ea60baf

Browse files
committed
fixed open diff head
1 parent 462bc61 commit ea60baf

File tree

4 files changed

+31
-39
lines changed

4 files changed

+31
-39
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# **v1.0.2**
2+
3+
## Bug Fixes
4+
5+
* Diff against head should now work.
6+
* Update debounce was re-added by @edgardmessias
7+
18
# **v1.0.1**
29

310
## What's New

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svn-scm",
33
"displayName": "SVN",
44
"description": "Integrated Subversion source control",
5-
"version": "1.0.1",
5+
"version": "1.0.2",
66
"publisher": "johnstoncode",
77
"engines": {
88
"vscode": "^1.17.0"
@@ -54,7 +54,7 @@
5454
"category": "SVN"
5555
},
5656
{
57-
"command": "svn.openChanges",
57+
"command": "svn.openDiffHead",
5858
"title": "Diff Changes HEAD",
5959
"category": "SVN"
6060
},
@@ -99,7 +99,7 @@
9999
"group": "1_modification"
100100
},
101101
{
102-
"command": "svn.openChanges",
102+
"command": "svn.openDiffHead",
103103
"when": "scmProvider == svn && scmResourceGroup == changes",
104104
"group": "1_modification"
105105
}

src/commands.ts

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export class SvnCommands {
8181
options: { repository: true }
8282
},
8383
{
84-
commandId: "svn.openChanges",
85-
method: this.openChanges,
84+
commandId: "svn.openDiffHead",
85+
method: this.openDiffHead,
8686
options: {}
8787
},
8888
{
@@ -212,55 +212,40 @@ export class SvnCommands {
212212
repository.update();
213213
}
214214

215-
async openChanges(resource: Resource) {
216-
if (resource instanceof Resource) {
217-
this.openResource(resource, true);
218-
}
219-
}
220-
221-
private async openResource(
222-
resource: Resource,
223-
preview?: boolean,
224-
preserveFocus?: boolean,
225-
preserveSelection?: boolean
226-
) {
215+
async openDiff(resource: Resource, against: string) {
227216
const left = this.getLeftResource(resource);
228217
const right = this.getRightResource(resource);
229-
// const title = this.getTitle(resource);
230-
const title = "test";
218+
const title = this.getDiffTitle(resource, against);
231219

232220
if (!right) {
233221
return;
234222
}
235223

236224
if (!left) {
237-
window.showErrorMessage("File not found on HEAD");
225+
window.showErrorMessage(`No diff available at ${against}`);
238226
return;
239227
}
240228

241-
const options: TextDocumentShowOptions = {
242-
preserveFocus,
243-
preview
244-
};
229+
try {
230+
await commands.executeCommand("vscode.diff", left, right, title);
231+
} catch (error) {
232+
console.log(error);
233+
}
234+
}
245235

246-
const activeTextEditor = window.activeTextEditor;
236+
private getDiffTitle(resource: Resource, ref: string): string {
237+
let file = path.basename(resource.relativePath);
247238

248-
if (
249-
preserveSelection &&
250-
activeTextEditor &&
251-
activeTextEditor.document.uri.path === right.path
252-
) {
253-
options.selection = activeTextEditor.selection;
254-
}
239+
return `${file} (${ref})`;
240+
}
255241

256-
if (!preview) {
257-
await commands.executeCommand("vscode.open", right);
258-
} else {
259-
await commands.executeCommand("vscode.diff", left, right, title);
242+
async openDiffHead(resource: Resource) {
243+
if (resource instanceof Resource) {
244+
this.openDiff(resource, "HEAD");
260245
}
261246
}
262247

263-
private async getURI(uri: Uri, ref: string) {
248+
private getURI(uri: Uri, ref: string): Uri {
264249
return toSvnUri(uri, ref);
265250
}
266251

@@ -273,7 +258,7 @@ export class SvnCommands {
273258

274259
switch (resource.type) {
275260
case "modified":
276-
return this.getURI(resource.resourceUri, "~");
261+
return this.getURI(resource.resourceUri, "HEAD");
277262
default:
278263
return false;
279264
}

src/uri.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Uri } from "vscode";
22

3-
export function toSvnUri(uri: Uri, ref: string) {
3+
export function toSvnUri(uri: Uri, ref: string): Uri {
44
return uri.with({
55
scheme: "svn",
66
path: uri.path,

0 commit comments

Comments
 (0)