We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f44c2d commit 7aaebf0Copy full SHA for 7aaebf0
extension/src/extension.ts
@@ -82,7 +82,26 @@ export class Extension {
82
}
83
84
const selection = editor.selection;
85
- const selectedText = editor.document.getText(selection);
+
86
+ let selectedText;
87
+ if (selection.isEmpty) {
88
+ const lineText = editor.document.lineAt(selection.start)
89
+ .text;
90
+ const regexp = /`(.*)`/g;
91
+ selectedText = "";
92
+ let match;
93
+ while ((match = regexp.exec(lineText))) {
94
+ if (
95
+ match.index <= selection.start.character &&
96
+ selection.start.character <=
97
+ match.index + match[0].length
98
+ ) {
99
+ selectedText = match[1];
100
+ }
101
102
+ } else {
103
+ selectedText = editor.document.getText(selection);
104
105
106
if (!selectedText) {
107
return;
0 commit comments