Skip to content

Commit d74dd39

Browse files
committed
refactor(extension): Simplify action key detection logic
1 parent 73833d0 commit d74dd39

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/extension.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -375,35 +375,25 @@ async function isBelowActionKey(document: vscode.TextDocument, position: vscode.
375375

376376
if (document.languageId === 'typescript') {
377377
const lines = text.split('\n').reverse();
378-
let inActionsProp = false;
379378
for (const line of lines) {
380379
const trimmedLine = line.trim().toLowerCase();
381380
if (trimmedLine.includes('actions:') && trimmedLine.includes('[')) {
382-
inActionsProp = true;
383381
return true;
384382
}
385-
if (inActionsProp && (trimmedLine.startsWith(']') || trimmedLine.endsWith('],'))) {
386-
break;
387-
}
388-
if (trimmedLine.startsWith('new') || trimmedLine.includes('{')) {
383+
if (trimmedLine.startsWith('}') || trimmedLine.startsWith(']')) {
389384
break;
390385
}
391386
}
392387
}
393388

394389
if (document.languageId === 'python') {
395390
const lines = text.split('\n').reverse();
396-
let inActionsProp = false;
397391
for (const line of lines) {
398392
const trimmedLine = line.trim().toLowerCase();
399393
if (trimmedLine.startsWith('actions=') && trimmedLine.includes('[')) {
400-
inActionsProp = true;
401394
return true;
402395
}
403-
if (inActionsProp && (trimmedLine.endsWith(']') || trimmedLine.endsWith('],'))) {
404-
break;
405-
}
406-
if (trimmedLine.startsWith('iam.policystatement(') || trimmedLine.endsWith('=')) {
396+
if (trimmedLine.endsWith(']') || trimmedLine.endsWith('],')) {
407397
break;
408398
}
409399
}

0 commit comments

Comments
 (0)