Skip to content

Commit

Permalink
✨ Replace highlighted text with relative path (#44)
Browse files Browse the repository at this point in the history
* Overwrite selection. In case of multiple selections, first one will be replaced.

* Adding comments.

* reverting changes in package.json

* Package.lock file reverted.

Co-authored-by: daws.eth <dawsonbotsford@gmail.com>
  • Loading branch information
rapsalands and dawsbot committed May 7, 2022
1 parent b88e534 commit 446ec81
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,15 @@ class RelativePath {

window.activeTextEditor.edit(
(editBuilder: TextEditorEdit) => {
let position: Position = window.activeTextEditor.selection.end;
editBuilder.insert(position, relativeUrl);
// Get all selections
let selections = window.activeTextEditor.selections;

// Replace selections with relative Url.
selections.forEach(sel => {
editor.edit(editBuilder => {
editBuilder.replace(sel, relativeUrl);
});
});
}
);
}
Expand Down

0 comments on commit 446ec81

Please sign in to comment.