diff --git a/CHANGELOG.md b/CHANGELOG.md index a0fe3c4..0398f84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 2.0.5 (2021/12/24) + +### Fixes + +* Fix semantic exception when position is negative [#62](https://github.com/LuqueDaniel/vscode-language-renpy/issues/62) +* Fix (Uncompiled Game) status bar text when editing a non-Renpy workspace/file + ## 2.0.4 (2021/11/14) ### Changes and improvements diff --git a/package.json b/package.json index fd938ca..8bb5d90 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "languague-renpy", "displayName": "Ren'Py Language", "description": "Adds syntax highlighting and snippets to Ren'Py files in Visual Studio Code", - "version": "2.0.4", + "version": "2.0.5", "publisher": "LuqueDaniel", "license": "MIT", "homepage": "https://github.com/LuqueDaniel/vscode-language-renpy", diff --git a/src/navigationdata.ts b/src/navigationdata.ts index f1d3a06..7ef19fe 100644 --- a/src/navigationdata.ts +++ b/src/navigationdata.ts @@ -1086,6 +1086,10 @@ export function updateNavigationData(type: string, keyword: string, filename: st } export function getStatusBarText() { + if (!window.activeTextEditor || !window.activeTextEditor.document || window.activeTextEditor.document.languageId !== 'renpy') { + return ""; + } + if (NavigationData.data) { if (NavigationData.data.name !== undefined) { return `${NavigationData.data.name} v${NavigationData.data.version}`; diff --git a/src/semantics.ts b/src/semantics.ts index eafbe6c..85f9b07 100644 --- a/src/semantics.ts +++ b/src/semantics.ts @@ -102,7 +102,7 @@ export function getSemanticTokens(document: TextDocument, legend: SemanticTokens start += m.length + 1; } if (matches[1] === 'def') { - const context = getCurrentContext(document, new Position(i - 1, indent_level)); + const context = i - 1 < 0 ? undefined : getCurrentContext(document, new Position(i - 1, indent_level)); if (context === undefined) { updateNavigationData('callable', matches[2], filename, i); } else if (context.startsWith('store.')) { @@ -122,7 +122,7 @@ export function getSemanticTokens(document: TextDocument, legend: SemanticTokens parent_defaults = {}; if (matches[1] === 'def') { - const context = getCurrentContext(document, new Position(i - 1, indent_level)); + const context = i - 1 < 0 ? undefined : getCurrentContext(document, new Position(i - 1, indent_level)); if (context === undefined) { updateNavigationData('callable', matches[2], filename, i); } else if (context.startsWith('store.')) { @@ -133,7 +133,7 @@ export function getSemanticTokens(document: TextDocument, legend: SemanticTokens } } else if (matches[4] === 'label') { indent_level = line.length - line.trimLeft().length; - const context = getCurrentContext(document, new Position(i - 1, indent_level)); + const context = i - 1 < 0 ? undefined : getCurrentContext(document, new Position(i - 1, indent_level)); if (context === undefined) { updateNavigationData('label', matches[5], filename, i); }