gotoLine function
Command that shows a dialog asking for a line number.
Supports:
- Line numbers (e.g., "42")
- Relative line offsets (e.g., "+5", "-3")
- Document percentages (e.g., "50%")
- Column positions (e.g., "42:10" for line 42, column 10)
Implementation
bool gotoLine(EditorViewState view) {
// EditorViewState extends State so it has a context
if (!view.mounted) return false;
final context = view.context;
final state = view.state;
final currentLine = state.doc.lineAt(state.selection.main.head).number;
showDialog<void>(
context: context,
builder: (dialogContext) => _GotoLineDialog(
view: view,
initialLine: currentLine.toString(),
),
);
return true;
}