Skip to content

Commit

Permalink
Merge pull request #34 from livecodeAlexV/script-name-parsing-fix
Browse files Browse the repository at this point in the history
[[ live-server ]] Fix script names not being parsed correctly.
  • Loading branch information
WilliamDelRey authored May 1, 2024
2 parents 980f627 + 7e66045 commit 62fe77a
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/features/livecodescript/LCSserverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ export default class LivecodescriptServerProvider {
subscriptions.push(this);
subscriptions.push(
vscode.workspace.onDidSaveTextDocument(
async ({ fileName, languageId, lineAt }) => {
console.log("DOCUMENT SAVED");
if (this.enabled && languageId === "livecodescript") {
const regex = '"([-.:a-zA-Z0-9_s?!]+)"';
const scriptName = lineAt(0).text.match(regex)[1];
const query = {
command: "reload script",
stack: scriptName,
filename: fileName,
};
async ({ fileName, languageId, lineAt }) => {
console.log("DOCUMENT SAVED");
if (this.enabled && languageId === "livecodescript") {
const regex = /"([-.:a-zA-Z0-9_\s?!]+)"/;
const match = lineAt(0).text.match(regex)
/* if the regex finds nothing it returns null so we run a check to avoid erroring out */
const scriptName = match ? match[1] : null
const query = {
command: scriptName === null ? `Error parsing script name from file ${fileName}!` : "reload script",
stack: scriptName,
filename: fileName,
};

await this.sender.send(query);
}
}
)
);
await this.sender.send(query);
}
}
)
);
subscriptions.push(
vscode.workspace.onDidChangeConfiguration(() =>
this.loadConfiguration()
Expand Down

0 comments on commit 62fe77a

Please sign in to comment.