@@ -74,7 +74,8 @@ export async function evalGetIds(
74
74
const out = await runREPLCommand (
75
75
env . config ,
76
76
document ,
77
- c . evalIdentifiers ( prefix )
77
+ c . evalIdentifiers ( prefix ) ,
78
+ false
78
79
) ;
79
80
if ( out . error || out . stderr ) {
80
81
env . outChannel . appendLine (
@@ -103,7 +104,7 @@ export async function loadFile(
103
104
env : h . Env ,
104
105
editor : vscode . TextEditor
105
106
) : Promise < void > {
106
- const out = await runREPLCommand ( env . config , editor . document , "" ) ;
107
+ const out = await runREPLCommand ( env . config , editor . document , "" , false ) ;
107
108
if ( out . error ) {
108
109
env . outChannel . appendLine (
109
110
`Error checking file ${ editor . document . fileName } :\n${ out . error } \nStderr: ${ out . stderr } \nStdout: ${ out . stdout } `
@@ -304,7 +305,8 @@ async function evalSexp(
304
305
const out = await runREPLCommand (
305
306
env . config ,
306
307
data . editor . document ,
307
- data . exp . sexp
308
+ data . exp . sexp ,
309
+ true
308
310
) ;
309
311
env . outChannel . appendLine (
310
312
`Sent ${ data . exp . sexp } to REPL using command ${ c . cfgSection } .${ data . vscodeCommand } Range ${ data . range . start . line } - ${ data . range . end . line } `
@@ -398,19 +400,23 @@ function matchREPLResponse(group: string): RegExp {
398
400
* @param config The extension's configuration.
399
401
* @param document The source code containing the sexp to evaluate.
400
402
* @param exp The sexp to evaluate.
403
+ * @param checkForSave If `true`, check if the file has unsaved changes, and if
404
+ * so, ask the user to save them.
401
405
* @returns The output of the Chez REPL after loading the file of `editor` and
402
406
* evaluating `exp`.
403
407
*/
408
+ // eslint-disable-next-line max-params
404
409
async function runREPLCommand (
405
410
config : vscode . WorkspaceConfiguration ,
406
411
document : vscode . TextDocument ,
407
- exp : string
412
+ exp : string ,
413
+ checkForSave : boolean
408
414
) : Promise < h . Output > {
409
415
const root = await h . askForWorkspace ( "Scheme" ) ;
410
416
if ( document . isUntitled ) {
411
417
await document . save ( ) ;
412
418
}
413
- if ( document . isDirty ) {
419
+ if ( checkForSave && document . isDirty ) {
414
420
const response = await vscode . window . showWarningMessage (
415
421
"The file has unsaved changes, these will not be send to the REPL." ,
416
422
"Save changes and eval" ,
0 commit comments