-
We contribute links to specific text editor documents via |
Beta Was this translation helpful? Give feedback.
Answered by
lppedd
Sep 22, 2025
Replies: 1 comment
-
Apparently at the moment there is no built-in abstraction for this. const text = await editor.getText();
const coordinates = findStringCoordinates(text, "my link text");
assert.ok(coordinates, "...");
// Do not use moveCursor, it's slower
const [row, col] = coordinates;
await editor.setCursor(row, col);
// Select at least a character/word
await editor.getDriver().actions().keyDown(Key.SHIFT).sendKeys(Key.ARROW_RIGHT).perform();
const selection = await editor.getSelection();
assert.ok(selection, "missing editor selection");
// Pass the selection to click(...), otherwise nothing happens
await selection.getDriver().actions().keyDown(Key.CONTROL).click(selection).perform();
/* ... */
function findStringCoordinates(text: string, str: string): [number, number] | undefined {
const lines = text.split("\n");
for (let index = 0; index < lines.length; index++) {
const colIndex = lines[index].indexOf(str);
if (colIndex > -1) {
return [index + 1, colIndex + 1];
}
}
return undefined;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lppedd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently at the moment there is no built-in abstraction for this.
What I ended up doing is, as an example: