Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const vscode = require('vscode');

function activate(context) {


const disposable = vscode.commands.registerCommand('runRevCommands', async () => {

const editor = vscode.window.activeTextEditor;
Expand All @@ -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));
}
}
Expand Down