From 1a33b213becd99e14719efc38f21c7d0ac25ce32 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 24 Jul 2023 11:27:46 +0200 Subject: [PATCH] Added`Center Cursor` command --- plugs/core/core.plug.yaml | 5 +++++ plugs/core/editor.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/plugs/core/core.plug.yaml b/plugs/core/core.plug.yaml index 0cc19f98..c31d0232 100644 --- a/plugs/core/core.plug.yaml +++ b/plugs/core/core.plug.yaml @@ -26,6 +26,11 @@ functions: path: "./editor.ts:toggleDarkMode" command: name: "Editor: Toggle Dark Mode" + centerCursor: + path: "./editor.ts:centerCursorCommand" + command: + name: "Editor: Center Cursor" + key: "Ctrl-Alt-l" clearPageIndex: path: "./page.ts:clearPageIndex" events: diff --git a/plugs/core/editor.ts b/plugs/core/editor.ts index 59b22a3d..11782bc0 100644 --- a/plugs/core/editor.ts +++ b/plugs/core/editor.ts @@ -37,3 +37,8 @@ export async function foldAllCommand() { export async function unfoldAllCommand() { await editor.unfoldAll(); } + +export async function centerCursorCommand() { + const pos = await editor.getCursor(); + await editor.moveCursor(pos, true); +}