Skip to content
Snippets Groups Projects
Commit 2e72e1c3 authored by Thomas Wood's avatar Thomas Wood
Browse files

Use single eval panel, rather than multiple

parent f67e8a4f
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,9 @@ var Translate_syntax = { ...@@ -2,8 +2,9 @@ var Translate_syntax = {
eval_counter: 0, eval_counter: 0,
parse_esprima: function (strictness, src) { parse_esprima: function (strictness, src) {
try { try {
// TODO Fixup line numbers for eval context // EVAL: Uncomment line below to enable multiple eval tabs
return Some(parseSource(src, "_eval_" + Translate_syntax.eval_counter++, true)); //return Some(parseSource(src, "_eval_" + Translate_syntax.eval_counter++, true));
return Some(parseSource(src, "_eval_", true));
} catch (e) { } catch (e) {
return None(); return None();
} }
......
...@@ -117,18 +117,33 @@ function newSourceDoc(name, text, readOnly) { ...@@ -117,18 +117,33 @@ function newSourceDoc(name, text, readOnly) {
.text(name) .text(name)
.click(e => selectSourceDoc(e.target.textContent)) .click(e => selectSourceDoc(e.target.textContent))
.appendTo('#source_tabs'); .appendTo('#source_tabs');
if (name === '_eval_') { tab.hide(); }
source_docs[name].doc_name = name;
source_docs[name].tab = tab; source_docs[name].tab = tab;
source_docs[name].readOnly = Boolean(readOnly); source_docs[name].readOnly = Boolean(readOnly);
} }
return source_docs[name]; return source_docs[name];
} }
function selectSourceDocFromLoc(loc) {
var name = loc.file;
if (name === '_eval_') {
source_docs['_eval_'].tab.show();
source_docs['_eval_'].setValue(loc.sourceText);
}
var old_doc = selectSourceDoc(loc.file);
if (old_doc.doc_name === "_eval_" && name !== "_eval_") {
source_docs['_eval_'].tab.hide();
}
}
// Switches current source doc // Switches current source doc
function selectSourceDoc(name) { function selectSourceDoc(name) {
var old_doc = source.swapDoc(source_docs[name]); var old_doc = source.swapDoc(source_docs[name]);
if (old_doc.tab) old_doc.tab.removeClass('file_item_current'); if (old_doc.tab) old_doc.tab.removeClass('file_item_current');
source_docs[name].tab.addClass('file_item_current'); source_docs[name].tab.addClass('file_item_current');
source.setOption('readOnly', source_docs[name].readOnly); source.setOption('readOnly', source_docs[name].readOnly);
return old_doc;
} }
// Sets the initial source doc // Sets the initial source doc
...@@ -1141,9 +1156,7 @@ function updateSelection() { ...@@ -1141,9 +1156,7 @@ function updateSelection() {
// source panel // source panel
source_loc_selected = item.source_loc; source_loc_selected = item.source_loc;
newSourceDoc(item.source_loc.file, item.source_loc.sourceText); selectSourceDocFromLoc(source_loc_selected);
selectSourceDoc(item.source_loc.file);
updateSelectionInCodeMirror(source, source_loc_selected); updateSelectionInCodeMirror(source, source_loc_selected);
// console.log(source_loc_selected); // console.log(source_loc_selected);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment