From 2e72e1c3b3e00e9a835899a8f0a9b91c3b6cf80b Mon Sep 17 00:00:00 2001 From: Thomas Wood <thomas.wood09@imperial.ac.uk> Date: Wed, 6 Apr 2016 17:57:27 +0100 Subject: [PATCH] Use single eval panel, rather than multiple --- generator/tests/jsref/Translate_syntax.js | 5 +++-- navig-driver.js | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/generator/tests/jsref/Translate_syntax.js b/generator/tests/jsref/Translate_syntax.js index 550d195..df83e1b 100644 --- a/generator/tests/jsref/Translate_syntax.js +++ b/generator/tests/jsref/Translate_syntax.js @@ -2,8 +2,9 @@ var Translate_syntax = { eval_counter: 0, parse_esprima: function (strictness, src) { try { - // TODO Fixup line numbers for eval context - return Some(parseSource(src, "_eval_" + Translate_syntax.eval_counter++, true)); + // EVAL: Uncomment line below to enable multiple eval tabs + //return Some(parseSource(src, "_eval_" + Translate_syntax.eval_counter++, true)); + return Some(parseSource(src, "_eval_", true)); } catch (e) { return None(); } diff --git a/navig-driver.js b/navig-driver.js index bae27ce..37b2c72 100644 --- a/navig-driver.js +++ b/navig-driver.js @@ -117,18 +117,33 @@ function newSourceDoc(name, text, readOnly) { .text(name) .click(e => selectSourceDoc(e.target.textContent)) .appendTo('#source_tabs'); + if (name === '_eval_') { tab.hide(); } + source_docs[name].doc_name = name; source_docs[name].tab = tab; source_docs[name].readOnly = Boolean(readOnly); } 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 function selectSourceDoc(name) { var old_doc = source.swapDoc(source_docs[name]); if (old_doc.tab) old_doc.tab.removeClass('file_item_current'); source_docs[name].tab.addClass('file_item_current'); source.setOption('readOnly', source_docs[name].readOnly); + return old_doc; } // Sets the initial source doc @@ -1141,9 +1156,7 @@ function updateSelection() { // source panel source_loc_selected = item.source_loc; - newSourceDoc(item.source_loc.file, item.source_loc.sourceText); - selectSourceDoc(item.source_loc.file); - + selectSourceDocFromLoc(source_loc_selected); updateSelectionInCodeMirror(source, source_loc_selected); // console.log(source_loc_selected); -- GitLab