Skip to content

Commit

Permalink
Merge pull request #2 from Release-Candidate/fix-windows-file-paths-c…
Browse files Browse the repository at this point in the history
…ontaining-backslashes-in-load

Fix escaping of backslashes in file paths see #1
  • Loading branch information
Release-Candidate authored Jun 26, 2023
2 parents 3170976 + 7b54b49 commit 90ad1c1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Chez Scheme REPL for Visual Studio Code Changelog

## Version 0.2.0 (2023-06-26)

### Bugfixes

- Fix [#1](https://github.com/Release-Candidate/vscode-scheme-repl/issues/1). Evaluating does not work on Windows, because backslashes in Windows file paths are not escaped. Leads to Chez error messages like `Exception in read: invalid string character \U` for a file path `C:\User\...`.

## Version 0.1.0 (2023-06-23)

Initial release
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-scheme-repl",
"displayName": "Chez Scheme REPL",
"version": "0.1.0",
"version": "0.2.0",
"preview": false,
"publisher": "release-candidate",
"description": "Support for Chez Scheme.",
Expand Down
5 changes: 4 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export function setREPLPrompt(prompt: string): string {
/**
* Return the command to send to a running Chez REPL to load the file
* `fileName` and evaluate `sexp`.
* Escapes backslashes in the file path (Windows paths) to be able to load files
* on windows.
* The lambda to `load` helps in getting a bit of context about an error, if an
* error occurs when loading `fileName`.
* Set the REPL prompt to `replPrompt`.
Expand All @@ -74,7 +76,8 @@ export function setREPLPrompt(prompt: string): string {
* `fileName` and evaluate `sexp`.
*/
export function replLoadFileAndSexp(fileName: string, sexp: string): string {
return `(load "${fileName}" (lambda (x) (pretty-print (if (annotation? x) (annotation-stripped x) x)) (newline) (eval x)))\n${setREPLPrompt(
const sanitized = fileName.replace(/\\/gu, "\\\\");
return `(load "${sanitized}" (lambda (x) (pretty-print (if (annotation? x) (annotation-stripped x) x)) (newline) (eval x)))\n${setREPLPrompt(
replPrompt
)}\n ${sexp}`;
}
Expand Down
4 changes: 2 additions & 2 deletions src/paneREPL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function expandLastInRepl(
}

/**
* Send the result of applying `f` to the current selection to the pane REPL.
* Send the result of applying `data.f` to the current selection to the pane REPL.
* @param data The needed data.
*/
async function doSelectionInRepl(data: {
Expand Down Expand Up @@ -155,7 +155,7 @@ async function doSelectionInRepl(data: {
}

/**
* Send the result of applying `f` to the sexp to the left of the cursor to the
* Send the result of applying `data.f` to the sexp to the left of the cursor to the
* pane REPL.
* @param data The needed data.
*/
Expand Down

0 comments on commit 90ad1c1

Please sign in to comment.