diff --git a/src/web/App.mjs b/src/web/App.mjs index 2ea55708..1697cdf1 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -502,6 +502,16 @@ class App { this.manager.output.chrEncChange(parseInt(this.uriParams.oenc, 10)); } + // Input EOL sequence + if (this.uriParams.ieol) { + this.manager.input.eolChange(this.uriParams.ieol); + } + + // Output EOL sequence + if (this.uriParams.oeol) { + this.manager.output.eolChange(this.uriParams.oeol); + } + // Read in input data from URI params if (this.uriParams.input) { try { diff --git a/src/web/waiters/ControlsWaiter.mjs b/src/web/waiters/ControlsWaiter.mjs index fe2e9f9f..6a0ef6f2 100755 --- a/src/web/waiters/ControlsWaiter.mjs +++ b/src/web/waiters/ControlsWaiter.mjs @@ -140,12 +140,16 @@ class ControlsWaiter { const inputChrEnc = this.manager.input.getChrEnc(); const outputChrEnc = this.manager.output.getChrEnc(); + const inputEOLSeq = this.manager.input.getEOLSeq(); + const outputEOLSeq = this.manager.output.getEOLSeq(); const params = [ includeRecipe ? ["recipe", recipeStr] : undefined, includeInput && input.length ? ["input", Utils.escapeHtml(input)] : undefined, inputChrEnc !== 0 ? ["ienc", inputChrEnc] : undefined, - outputChrEnc !== 0 ? ["oenc", outputChrEnc] : undefined + outputChrEnc !== 0 ? ["oenc", outputChrEnc] : undefined, + inputEOLSeq !== "\n" ? ["ieol", inputEOLSeq] : undefined, + outputEOLSeq !== "\n" ? ["oeol", outputEOLSeq] : undefined ]; const hash = params diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index 9f584a98..7ab5c1db 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -142,6 +142,14 @@ class InputWaiter { this.setInput(oldInputVal); } + /** + * Getter for the input EOL sequence + * @returns {string} + */ + getEOLSeq() { + return this.inputEditorView.state.lineBreak; + } + /** * Handler for Chr Enc change events * Sets the input character encoding @@ -179,7 +187,7 @@ class InputWaiter { */ getInput() { const doc = this.inputEditorView.state.doc; - const eol = this.inputEditorView.state.lineBreak; + const eol = this.getEOLSeq(); return doc.sliceString(0, doc.length, eol); } @@ -644,7 +652,7 @@ class InputWaiter { buffer: buffer, stringSample: stringSample, encoding: this.getChrEnc(), - eolSequence: this.inputEditorView.state.lineBreak + eolSequence: this.getEOLSeq() } }, transferable); } diff --git a/src/web/waiters/OutputWaiter.mjs b/src/web/waiters/OutputWaiter.mjs index 08e870e6..b58cacd9 100755 --- a/src/web/waiters/OutputWaiter.mjs +++ b/src/web/waiters/OutputWaiter.mjs @@ -142,7 +142,22 @@ class OutputWaiter { }); // Reset the output so that lines are recalculated, preserving the old EOL values - this.setOutput(oldOutputVal); + this.setOutput(oldOutputVal, true); + // Update the URL manually since we aren't firing a statechange event + this.app.updateURL(true); + } + + /** + * Getter for the output EOL sequence + * Prefer reading value from `this.outputs` since the editor may not have updated yet. + * @returns {string} + */ + getEOLSeq() { + const currentTabNum = this.manager.tabs.getActiveTab("output"); + if (currentTabNum < 0) { + return this.outputEditorConf.state.lineBreak; + } + return this.outputs[currentTabNum].eolSequence; } /**