Skip to content

Commit 446ec81

Browse files
rapsalandsdawsbot
andauthored
✨ Replace highlighted text with relative path (#44)
* 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 <[email protected]>
1 parent b88e534 commit 446ec81

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/extension.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,15 @@ class RelativePath {
219219

220220
window.activeTextEditor.edit(
221221
(editBuilder: TextEditorEdit) => {
222-
let position: Position = window.activeTextEditor.selection.end;
223-
editBuilder.insert(position, relativeUrl);
222+
// Get all selections
223+
let selections = window.activeTextEditor.selections;
224+
225+
// Replace selections with relative Url.
226+
selections.forEach(sel => {
227+
editor.edit(editBuilder => {
228+
editBuilder.replace(sel, relativeUrl);
229+
});
230+
});
224231
}
225232
);
226233
}

0 commit comments

Comments
 (0)