diff --git a/examples/unit_test.rpy b/examples/unit_test.rpy index d1a2788..6f32742 100644 --- a/examples/unit_test.rpy +++ b/examples/unit_test.rpy @@ -23,6 +23,13 @@ define s = Character('Sylvie', color="#f44747") define s = Character('Sylvie', color="#808080") + default name1="foo" + default name2="bar" + default names=list(["[name1]","[name2][[]"]) + + label start: + $ my_list = ["[name1]]"] + define m = Character('Me', color="#c8c8ff") image logo = "renpy logo.png" diff --git a/src/diagnostics.ts b/src/diagnostics.ts index 2d49467..57e7e31 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -1,8 +1,9 @@ // Diagnostics (warnings and errors) -import { commands, Diagnostic, DiagnosticCollection, DiagnosticSeverity, Disposable, ExtensionContext, FileType, languages, Range, TextDocument, Uri, window, workspace } from "vscode"; +import { commands, Diagnostic, DiagnosticCollection, DiagnosticSeverity, Disposable, ExtensionContext, FileType, languages, LogLevel, Range, TextDocument, Uri, window, workspace } from "vscode"; import { NavigationData } from "./navigation-data"; import { getAllOpenTabInputTextUri } from "./utilities/functions"; import { extractFilename } from "./workspace"; +import { LogCategory, logCatMessage } from "./logger"; // Renpy Store Variables (https://www.renpy.org/doc/html/store_variables.html) // These variables do not begin with '_' but should be ignored by store warnings because they are pre-defined by Ren'Py @@ -202,17 +203,21 @@ function refreshDiagnostics(doc: TextDocument, diagnosticCollection: DiagnosticC function refreshOpenDocuments(diagnosticCollection: DiagnosticCollection) { diagnosticCollection.clear(); const tabInputTextUris = getAllOpenTabInputTextUri(); - tabInputTextUris.forEach((uri) => { - diagnoseFromUri(uri, diagnosticCollection); + tabInputTextUris.forEach(async (uri) => { + await diagnoseFromUri(uri, diagnosticCollection); }); } -function diagnoseFromUri(uri: Uri, diagnosticCollection: DiagnosticCollection) { - workspace.fs.stat(uri).then((stat) => { - if (stat.type === FileType.File) { +async function diagnoseFromUri(uri: Uri, diagnosticCollection: DiagnosticCollection) { + try { + const fileInfo = await workspace.fs.stat(uri); + + if (fileInfo.type === FileType.File) { workspace.openTextDocument(uri).then((document) => refreshDiagnostics(document, diagnosticCollection)); } - }); + } catch (error) { + logCatMessage(LogLevel.Error, LogCategory.Default, error as string); + } } function onDeleteFromWorkspace(uri: Uri, diagnosticCollection: DiagnosticCollection) { diff --git a/syntaxes/renpy.atl.tmLanguage.json b/syntaxes/renpy.atl.tmLanguage.json index 4877754..76ef0ed 100644 --- a/syntaxes/renpy.atl.tmLanguage.json +++ b/syntaxes/renpy.atl.tmLanguage.json @@ -401,6 +401,7 @@ "name": "entity.name.type.transform.renpy", "match": "\\b([[:alpha:]_]\\w*)\\b" }, + { "include": "source.renpy.python#parameters" }, { "include": "source.renpy#whitespace" } ] } diff --git a/syntaxes/renpy.python.tmLanguage.json b/syntaxes/renpy.python.tmLanguage.json index dbdbd46..9ea481e 100644 --- a/syntaxes/renpy.python.tmLanguage.json +++ b/syntaxes/renpy.python.tmLanguage.json @@ -1996,11 +1996,11 @@ }, "string-quoted-single-line": { "name": "string.quoted.single.python", - "begin": "(\\b[rRuU])?(\\b\\w+)?(['\"])", + "begin": "(?:\\b([rR])(?=[uU]))?([uU])?(['\"])", "end": "(\\3)|((?