Skip to content

Commit

Permalink
Merge pull request #63 from rdurfee/master
Browse files Browse the repository at this point in the history
Fix semantic exception and status bar text
  • Loading branch information
LuqueDaniel authored Dec 23, 2021
2 parents 3ae5dc1 + 9c27e18 commit 9c8016a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/navigationdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
6 changes: 3 additions & 3 deletions src/semantics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.')) {
Expand All @@ -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.')) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 9c8016a

Please sign in to comment.