From 93bd4dc8fe08cb0b075caac4e4dc0993a49a0ed8 Mon Sep 17 00:00:00 2001
From: KevinWh0 <45321184+KevinWh0@users.noreply.github.com>
Date: Fri, 2 Feb 2024 21:32:08 +0100
Subject: [PATCH] added lines and lines to errors

---
 packages/frontend/src/components/MkCode.core.vue  | 15 +++++++++++++++
 packages/frontend/src/components/MkCodeEditor.vue |  2 ++
 packages/frontend/src/scripts/install-plugin.ts   |  6 +++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/packages/frontend/src/components/MkCode.core.vue b/packages/frontend/src/components/MkCode.core.vue
index 579c72b186..77a01627ba 100644
--- a/packages/frontend/src/components/MkCode.core.vue
+++ b/packages/frontend/src/components/MkCode.core.vue
@@ -58,6 +58,21 @@ watch(() => props.lang, (to) => {
 </script>
 
 <style scoped lang="scss">
+.codeBlockRoot :deep(.shiki) > code {
+  counter-reset: step;
+  counter-increment: step 0;
+}
+
+.codeBlockRoot :deep(.shiki) > code > .line::before {
+  content: counter(step);
+  counter-increment: step;
+  width: 1rem;
+  margin-right: 1.5rem;
+  display: inline-block;
+  text-align: right;
+  color: rgba(115,138,148,.4)
+}
+
 .codeBlockRoot :deep(.shiki) {
 	padding: 1em;
 	margin: .5em 0;
diff --git a/packages/frontend/src/components/MkCodeEditor.vue b/packages/frontend/src/components/MkCodeEditor.vue
index 789acbd4c1..7334fc4d0e 100644
--- a/packages/frontend/src/components/MkCodeEditor.vue
+++ b/packages/frontend/src/components/MkCodeEditor.vue
@@ -204,6 +204,8 @@ watch(v, newValue => {
 	min-width: calc(100% - 24px);
 	height: 100%;
 	padding: 12px;
+	// the +2.5 rem is because of the line numbers
+	padding-left: calc(12px + 2.5rem);
 	line-height: 1.5em;
 	font-size: 1em;
 	font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;
diff --git a/packages/frontend/src/scripts/install-plugin.ts b/packages/frontend/src/scripts/install-plugin.ts
index ee218df018..1d1a8a3f77 100644
--- a/packages/frontend/src/scripts/install-plugin.ts
+++ b/packages/frontend/src/scripts/install-plugin.ts
@@ -64,7 +64,11 @@ export async function parsePluginMeta(code: string): Promise<AiScriptPluginMeta>
 	try {
 		ast = parser.parse(code);
 	} catch (err) {
-		throw new Error('Aiscript syntax error');
+		if (err instanceof Error) {
+			throw new Error(`Aiscript syntax error\n${(err as Error).message}`);
+		} else {
+			throw new Error('Aiscript syntax error');
+		}
 	}
 
 	const meta = Interpreter.collectMetadata(ast);
-- 
GitLab