Skip to content

Commit 6ba6182

Browse files
committed
feat-fix: correct position for hover values after colon
1 parent 3682d67 commit 6ba6182

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

src/flowr/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface FlowrSession {
3737
}
3838

3939
export function getPositionAt(position: vscode.Position, document: vscode.TextDocument): vscode.Range | undefined {
40-
const re = /([a-zA-Z0-9._:])+/;
40+
const re = /([a-zA-Z0-9._])+/;
4141
const wordRange = document.getWordRangeAtPosition(position, re);
4242
return wordRange;
4343
}

src/test/hover-values.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as vscode from 'vscode';
2+
import { activateExtension, openTestFile } from './test-util';
3+
import assert from 'assert';
4+
5+
6+
suite('hover values', () => {
7+
let editor: vscode.TextEditor;
8+
9+
const tc = async(pos: vscode.Position, expected: string) => {
10+
const result: vscode.Hover[] = await vscode.commands.executeCommand('vscode.executeHoverProvider', editor.document.uri, pos);
11+
assert.ok(result);
12+
assert.equal(result.length, 1);
13+
14+
const hover = result[0].contents[0] as vscode.MarkdownString;
15+
assert.equal(hover.value, `**Inferred Value**\n\n${expected}`);
16+
};
17+
18+
suiteSetup(async() => {
19+
await activateExtension();
20+
editor = await openTestFile('hover-values-example.R');
21+
});
22+
23+
test.only('shows inferred value for variable', async() => {
24+
await tc(new vscode.Position(0, 1), '[2L, 2L]');
25+
await tc(new vscode.Position(0, 5), '[2L, 2L]');
26+
});
27+
28+
test.only('shows inferred value correctly in sequences', async() => {
29+
await tc(new vscode.Position(1, 5), '[3L, 3L]');
30+
await tc(new vscode.Position(1, 7), '[40L, 40L]');
31+
});
32+
33+
test.only('shows inferred value for dataframe', async() => {
34+
const df = `Dataframe Shape:
35+
| | |
36+
|----|----|
37+
| Rows: | [3, 3] |
38+
| Cols: | [2, 2] |
39+
40+
Known Columns: \`id\`, \`label\``;
41+
await tc(new vscode.Position(2, 1), df);
42+
});
43+
});
44+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
X <- 2
2+
Y <- 3:40
3+
df <- data.frame(id = 1:3, label = c("A", "B", "C"))

0 commit comments

Comments
 (0)