fix preserving original sourceId after running script notes, fixes #2224

This commit is contained in:
zadam
2021-10-12 21:41:25 +02:00
parent 1cdd644b8f
commit 6738f2cd24
2 changed files with 8 additions and 4 deletions

View File

@@ -30,11 +30,12 @@ function executeBundle(bundle, apiParams = {}) {
apiParams.startNote = bundle.note;
}
const originalSourceId = cls.get('sourceId');
cls.set('sourceId', 'script');
// last \r\n is necessary if script contains line comment on its last line
const script = "function() {\r\n" + bundle.script + "\r\n}";
const ctx = new ScriptContext(bundle.allNotes, apiParams);
try {
@@ -45,6 +46,9 @@ function executeBundle(bundle, apiParams = {}) {
throw e;
}
finally {
cls.set('sourceId', originalSourceId);
}
}
/**