From e91c833658c6a14cbdf98e6586e1d382936dbdb6 Mon Sep 17 00:00:00 2001 From: Wenjie Zhu Date: Fri, 20 Feb 2026 16:44:39 +0100 Subject: [PATCH] Skip empty and comment lines on Cmd+Enter --- src/extension.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/extension.js b/src/extension.js index e3b0278..689ec22 100644 --- a/src/extension.js +++ b/src/extension.js @@ -2,7 +2,7 @@ const vscode = require('vscode'); function activate(context) { - + const disposable = vscode.commands.registerCommand('runRevCommands', async () => { const editor = vscode.window.activeTextEditor; @@ -11,12 +11,22 @@ function activate(context) { if (editor.selection.isEmpty) { const pos = editor.selection.active; - const nextLine = pos.line + 1; + const doc = editor.document; + + // Find next executable line (non-empty, non-comment) + let nextLine = pos.line + 1; + while (nextLine < doc.lineCount) { + const lineText = doc.lineAt(nextLine).text.trim(); + if (lineText.length > 0 && !lineText.startsWith('#')) { + break; + } + nextLine++; + } - if (nextLine < editor.document.lineCount) { - const nextLineLength = editor.document.lineAt(nextLine).text.length; + if (nextLine < doc.lineCount) { + const nextLineLength = doc.lineAt(nextLine).text.length; const newPos = new vscode.Position(nextLine, nextLineLength); - editor.selection = new vscode.Selection(newPos, newPos);; + editor.selection = new vscode.Selection(newPos, newPos); editor.revealRange(new vscode.Range(newPos, newPos)); } }