Skip to content

Commit 4d37ab6

Browse files
committed
fix #1123
1 parent 1d4ab62 commit 4d37ab6

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/test/definitions/code.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let autoCompPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'python
1818
const fileOne = path.join(autoCompPath, 'one.py');
1919
const fileTwo = path.join(autoCompPath, 'two.py');
2020
const fileThree = path.join(autoCompPath, 'three.py');
21+
const fileDecorator = path.join(autoCompPath, 'decorators.py');
2122
const fileEncoding = path.join(autoCompPath, 'four.py');
2223
const fileEncodingUsed = path.join(autoCompPath, 'five.py');
2324

@@ -72,6 +73,26 @@ suite('Code Definition', () => {
7273
}).then(done, done);
7374
});
7475

76+
test('Go to function with decorator', async () => {
77+
const textDocument = await vscode.workspace.openTextDocument(fileDecorator);
78+
await vscode.window.showTextDocument(textDocument);
79+
const position = new vscode.Position(7, 2);
80+
const def = await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', textDocument.uri, position);
81+
assert.equal(def.length, 1, 'Definition length is incorrect');
82+
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '4,0', 'Start position is incorrect');
83+
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '5,22', 'End position is incorrect');
84+
});
85+
86+
test('Go to function decorator', async () => {
87+
const textDocument = await vscode.workspace.openTextDocument(fileDecorator);
88+
await vscode.window.showTextDocument(textDocument);
89+
const position = new vscode.Position(3, 3);
90+
const def = await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', textDocument.uri, position);
91+
assert.equal(def.length, 1, 'Definition length is incorrect');
92+
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '0,0', 'Start position is incorrect');
93+
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '1,12', 'End position is incorrect');
94+
});
95+
7596
test('Across files', done => {
7697
let textEditor: vscode.TextEditor;
7798
let textDocument: vscode.TextDocument;

0 commit comments

Comments
 (0)