diff --git a/CHANGELOG.md b/CHANGELOG.md index cadafba..61585ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,3 +75,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ### Fixed - File display not showing if directory does not exist. + +## [1.1.5] - 2024-02-05 + +### Fixed +- Fix JSON to Lua table regex with numeric keys. diff --git a/package.json b/package.json index 6134688..45d7f6f 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.4", + "version": "1.1.5", "icon": "docs/img/icon.png", "repository": { "type": "git", diff --git a/src/extension.ts b/src/extension.ts index e820667..749d5b0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -61,7 +61,7 @@ async function runLua(lua: string, outputChannel: vscode.OutputChannel, filename // 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(/\["_([0-9]+)"\]\s*=/g, '[$1] ='); // Replace ["_n"] = with [n] = 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