Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jul 24, 2022
2 parents b505ea6 + 571afe2 commit b927fdd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/features/copyVariableName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ export const registerCopyVariableName = () => {
const activeEditor = vscode.window.activeTextEditor
if (!activeEditor || activeEditor.viewColumn === undefined) return
// also would make sense to support mutliple selections/cursors
let varName: string | undefined
const lineText = activeEditor.document.lineAt(activeEditor.selection.end).text
const constName = /\s*(?:const(?: {)?|let(?: {)?|type|interface|import(?: {)?) ([\w\d]+)/.exec(lineText)?.[1]
varName = constName
const regexps = [/\s*(?:const(?: {)?|let(?: {)?|type|interface|import(?: {)?) ([\w\d]+)/, /\.([\w\d-]+?)\s*{/]
let varName: string | undefined
for (const regexp of regexps) {
varName = regexp.exec(lineText)?.[1]
if (varName) break
}

if (!varName) {
// TODO replaceDocumentation?: (str
const match = /\s*(?:(?:['"](.+)['"])|(.+)):/.exec(lineText)
Expand Down

0 comments on commit b927fdd

Please sign in to comment.