From b11fc3f1d750ea4d9116e45818609a47dcdb8c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omelette=20=E8=9B=8B=E5=8D=B7?= Date: Sun, 4 Feb 2024 08:08:54 -0500 Subject: [PATCH] Release 1.1.3 --- CHANGELOG.md | 7 ++++++- package.json | 2 +- src/extension.ts | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 301ff08..083288b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,4 +60,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## [1.1.2] - 2024-02-03 ### Fixed -- Fix output panel still opening when return display is set to file. \ No newline at end of file +- Fix output panel still opening when return display is set to file. + +## [1.1.3] - 2024-02-04 + +### Fixed +- Fix JSON to Lua table regex. \ No newline at end of file diff --git a/package.json b/package.json index e70d20b..636319e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Quickly run lua code in DCS World (local or remote server). A reimplementation of the DCS Fiddle lua console in VS Code.", "license": "MIT", "publisher": "omltcat", - "version": "1.1.2", + "version": "1.1.3", "icon": "docs/img/icon.png", "repository": { "type": "git", diff --git a/src/extension.ts b/src/extension.ts index abd0504..077a767 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -52,10 +52,11 @@ async function runLua(lua: string, outputChannel: vscode.OutputChannel, filename } let luaString = jsonString; - // Replace JSON syntax with Lua syntax + // Replace JSON syntax with Lua syntax + luaString = luaString.replace(/null/g, 'nil'); // Replace null with nil luaString = luaString.replace(/"([^"]+)":/g, '["$1"] ='); // Replace "key": with ["key"] = luaString = luaString.replace(/"_([0-9]+)":/g, '[$1] ='); // Replace "_n": with [n] = - luaString = luaString.replace(/null/g, 'nil'); // Replace null with nil + luaString = luaString.replace(/\[\]/g, '{}'); // Replace [] with {} luaString = luaString.replace(/\[\n/g, '{\n'); // Replace [ followed by a line break with { followed by a line break luaString = luaString.replace(/]\n/g, '}\n'); // Replace ] followed by a line break with } followed by a line break luaString = luaString.replace(/],/g, '},'); // Replace ], with },