Skip to content

Commit c09d540

Browse files
Merge pull request #26 from Release-Candidate/warning_opoup_on_unsaved_eval_and_escaped_quote_parsing
Warning popup on unsaved changes when evaluating inline and fix parsing of escaped quotes
2 parents c6308b5 + 1c0b41f commit c09d540

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Chez Scheme REPL for Visual Studio Code Changelog
22

3+
## Version 0.7.1 (2024-07-13)
4+
5+
Special thanks to [migraine-user](https://github.com/migraine-user) for helping with these:
6+
7+
Add a popup warning if the file has unsaved changes before inline evaluating some expression.
8+
9+
### Bugfixes
10+
11+
- Fix the S-expression parser's handling of escaped quotes in strings
12+
313
## Version 0.7.0 (2024-07-12)
414

515
New command `Chez Scheme REPL: Remove all evaluated values from the view.`, `chezScheme.removeEvalVals` to remove all evaluated values from the current view.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-scheme-repl",
33
"displayName": "Chez Scheme REPL",
4-
"version": "0.7.0",
4+
"version": "0.7.1",
55
"preview": false,
66
"publisher": "release-candidate",
77
"description": "Support for Chez Scheme: Highlighting, autocompletion, documentation on hover and syntax checks.",

src/evalREPL.ts

+10
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ async function runREPLCommand(
410410
if (document.isUntitled) {
411411
await document.save();
412412
}
413+
if (document.isDirty) {
414+
const response = await vscode.window.showWarningMessage(
415+
"The file has unsaved changes, these will not be send to the REPL.",
416+
"Save changes and eval",
417+
"Eval without saving"
418+
);
419+
if (response === "Save changes and eval") {
420+
await document.save();
421+
}
422+
}
413423
return h.runCommand({
414424
root: root ? root.uri.fsPath : "./",
415425
args: [c.replQuietArg],

src/sexps.ts

+24-2
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,26 @@ function endOfSexp(data: {
377377
delimString: "{",
378378
});
379379
} else if (data.s.endsWith('"') && data.delim === "Quote") {
380+
let toCheck = data.s.slice(0, -1);
381+
let numBackSlash = 0;
382+
let backSlashes = "";
383+
while (toCheck.endsWith("\\")) {
384+
toCheck = toCheck.slice(0, -1);
385+
numBackSlash += 1;
386+
backSlashes += "\\";
387+
}
388+
// eslint-disable-next-line no-magic-numbers
389+
if (numBackSlash % 2 === 1) {
390+
return (
391+
parseSexpToLeft(
392+
data.delimStack,
393+
data.s.slice(0, -1 - numBackSlash),
394+
data.level
395+
) +
396+
backSlashes +
397+
'"'
398+
);
399+
}
380400
data.delimStack.pop();
381401
const newLevel = data.level - 1;
382402
if (newLevel === 0) {
@@ -385,9 +405,11 @@ function endOfSexp(data: {
385405
return (
386406
parseSexpToLeft(
387407
data.delimStack,
388-
data.s.slice(0, -1),
408+
data.s.slice(0, -1 - numBackSlash),
389409
newLevel
390-
) + '"'
410+
) +
411+
backSlashes +
412+
'"'
391413
);
392414
}
393415
}

test/sexps-test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ mocha.describe("Sexp parsing functions", () => {
238238
"Vector 'sdfgdgf #125vfx(255 0 255)' -> '#125vfx(255 0 255)' "
239239
);
240240
});
241+
mocha.it(
242+
'Escaped Quotes `not this \'[1 ("asd" ) "as\\"d" asdasd () ]`',
243+
() => {
244+
chai.assert.deepEqual(
245+
s.getSexpToLeft(
246+
'not this \'[1 ("asd" ) "as\\"d" asdasd () ]'
247+
),
248+
{
249+
sexp: '\'[1 ("asd" ) "as\\"d" asdasd () ]',
250+
startCol: 9,
251+
startLine: 0,
252+
},
253+
'Vector `not this \'[1 ("asd" ) "as\\"d" asdasd () ]` -> `\'[1 ("asd" ) "as\\"d" asdasd () ]`'
254+
);
255+
}
256+
);
241257
mocha.it("Gensym 'sdfgdgf #{g0 gdfgez754123245}'", () => {
242258
chai.assert.deepEqual(
243259
s.getSexpToLeft("sdfgdgf #{g0 gdfgez754123245}"),

0 commit comments

Comments
 (0)