Skip to content

Commit

Permalink
Web: handle query string input line by line
Browse files Browse the repository at this point in the history
This changes how input from a query string are handled.  Handling them
line by line produces output that more closely resembles how it would
have looked like when typed in interactively.

Closes #205
  • Loading branch information
eminence authored and sharkdp committed Oct 23, 2023
1 parent 155783b commit 17d3e69
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions numbat-wasm/www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function interpret(input) {
output = result.output;

if (!result.is_error) {
combined_input += input + "\n";
updateUrlQuery(combined_input.trim());
combined_input += input.trim() + "";
updateUrlQuery(combined_input);
}
}

Expand Down Expand Up @@ -87,7 +87,12 @@ function main() {
if (location.search) {
var queryParams = new URLSearchParams(location.search);
if (queryParams.has("q")) {
term.exec(queryParams.get("q"));
// feed in the query line by line, as if the user typed it in
for (const line of queryParams.get("q").split("⏎")) {
if (line.trim().length > 0) {
term.exec(line.trim() + "\n");
}
}
}
}
});
Expand Down

0 comments on commit 17d3e69

Please sign in to comment.