Skip to content

Commit 805414d

Browse files
author
dean
committed
add type annotation. don't add prev cursor position if multi select isn't picked
1 parent 6b50753 commit 805414d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

dist/main/atom/commands/goToDeclaration.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ registry_1.commands.set("typescript:go-to-declaration", deps => {
1818
const location = utils_1.getFilePathPosition();
1919
const client = yield deps.getClient(location.file);
2020
const result = yield client.executeDefinition(location);
21-
prevCursorPositions.push(location);
2221
if (result.body.length > 1) {
2322
simpleSelectionView_1.simpleSelectionView({
2423
items: result.body,
@@ -29,10 +28,14 @@ registry_1.commands.set("typescript:go-to-declaration", deps => {
2928
`;
3029
},
3130
filterKey: 'filePath',
32-
confirmed: item => open(item)
31+
confirmed: item => {
32+
prevCursorPositions.push(location);
33+
open(item);
34+
}
3335
});
3436
}
3537
else {
38+
prevCursorPositions.push(location);
3639
open(result.body[0]);
3740
}
3841
});

lib/main/atom/commands/goToDeclaration.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {commands} from "./registry"
2-
import {commandForTypeScript, getFilePathPosition} from "../utils"
2+
import {commandForTypeScript, getFilePathPosition, FileLocationQuery} from "../utils"
33
import {simpleSelectionView} from "../views/simpleSelectionView"
44

5-
const prevCursorPositions:any[] = [];
5+
const prevCursorPositions:FileLocationQuery[] = [];
66

77
function open(item: {file: string, start: {line: number, offset: number}}) {
88
atom.workspace.open(item.file, {
@@ -21,8 +21,6 @@ commands.set("typescript:go-to-declaration", deps => {
2121
const client = await deps.getClient(location.file)
2222
const result = await client.executeDefinition(location)
2323

24-
prevCursorPositions.push(location);
25-
2624
if (result.body!.length > 1) {
2725
simpleSelectionView({
2826
items: result.body!,
@@ -33,9 +31,13 @@ commands.set("typescript:go-to-declaration", deps => {
3331
`
3432
},
3533
filterKey: 'filePath',
36-
confirmed: item => open(item)
34+
confirmed: item => {
35+
prevCursorPositions.push(location);
36+
open(item)
37+
}
3738
})
3839
} else {
40+
prevCursorPositions.push(location);
3941
open(result.body![0])
4042
}
4143
}

0 commit comments

Comments
 (0)