Skip to content

Commit

Permalink
Move line highlighting after render (#237)
Browse files Browse the repository at this point in the history
Fix #231
  • Loading branch information
shaedrich committed Jun 30, 2024
1 parent 93cea59 commit 969747a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions static/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,9 @@
* @return {void}
*/
function fetchSnippet(session, result, snippet_file_name, do_evaluate, evaluateButton) {
var line = null
if (snippet_file_name.includes(':')) {
let [ snippet_file_name, line ] = snippet_file_name.split(':')
if (!Number.isNaN(+line)) {
editShowLine(line)
} else if (line.includes('-')) {
let [ startLine, endLine ] = line.split('-')
if (+startLine > +endLine) {
[ endLine, startLine ] = [ startLine, endLine ]
}
editShowRegion(startLine, 1, endLine, -1)
}
var [ snippet_file_name, line ] = snippet_file_name.split(':')
}
session.setValue("// Loading snippet: https://github.com/ponylang/pony-tutorial/blob/main/code-samples/" + snippet_file_name + " ...");
httpRequest("GET", "https://raw.githubusercontent.com/ponylang/pony-tutorial/main/code-samples/" + snippet_file_name, null, 200,
Expand All @@ -389,6 +381,18 @@
if (do_evaluate) {
doEvaluate();
}

if (line !== null) {
if (!Number.isNaN(+line)) {
editShowLine(line)
} else if (line.includes('-')) {
let [ startLine, endLine ] = line.split('-')
if (+startLine > +endLine) {
[ endLine, startLine ] = [ startLine, endLine ]
}
editShowRegion(startLine, 1, endLine, -1)
}
}
},
function (status, response) {
set_result(result, "<p class=error>Failed to fetch snippet" +
Expand Down

0 comments on commit 969747a

Please sign in to comment.