openInEditor method

  1. @override
Future<void> openInEditor(
  1. String path, {
  2. int? line,
  3. int? column,
})
override

Open path in the system editor, optionally jumping to line and column.

Implementation

@override
Future<void> openInEditor(String path, {int? line, int? column}) async {
  final editor = Platform.environment['EDITOR'] ?? 'code';
  final args = <String>[];

  if (editor.contains('code') || editor.contains('cursor')) {
    // VS Code / Cursor support --goto file:line:column.
    final loc = StringBuffer(path);
    if (line != null) loc.write(':$line');
    if (column != null) loc.write(':$column');
    args.addAll(['--goto', loc.toString()]);
  } else {
    // Fallback: just open the file.
    args.add(path);
  }

  await _runSimple(editor, args);
}