Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/web/waiters/InputWaiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,15 @@
* @param {string | ArrayBuffer} value
*/
updateInputValue(inputNum, value, force=false) {
// Preserve current selection
const inputElement = document.getElementById("input-text");
let selectionStart = null;
let selectionEnd = null;
if (inputElement) {
selectionStart = inputElement.selectionStart;
selectionEnd = inputElement.selectionEnd;
}

// Prepare the value as a buffer (full value) and a string sample (up to 4096 bytes)
let buffer;
let stringSample = "";
Expand Down Expand Up @@ -796,6 +805,14 @@
eolSequence: this.getEOLSeq()
}
}, transferable);

Check warning on line 808 in src/web/waiters/InputWaiter.mjs

View workflow job for this annotation

GitHub Actions / main

Trailing spaces not allowed
// Restore selection if it was set
if (inputElement && selectionStart !== null && selectionEnd !== null) {
requestAnimationFrame(() => {
inputElement.selectionStart = selectionStart;
inputElement.selectionEnd = selectionEnd;
});
}
}

/**
Expand Down
28 changes: 19 additions & 9 deletions src/web/waiters/OutputWaiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,27 @@
if (!this.outputExists(inputNum)) {
this.addOutput(inputNum);
}

if (Object.prototype.hasOwnProperty.call(data, "dish")) {
data.dish = new Dish(data.dish);
// Preserve current selection
const outputElement = document.getElementById("output-text");
let selectionStart = null;
let selectionEnd = null;
if (outputElement) {
selectionStart = outputElement.selectionStart;
selectionEnd = outputElement.selectionEnd;
}

this.outputs[inputNum].data = data;

const tabItem = this.manager.tabs.getTabItem(inputNum, "output");
if (tabItem) tabItem.style.background = "";

if (set) this.set(inputNum);
this.outputs[inputNum].statusMessage = statusMessage;

Check failure on line 563 in src/web/waiters/OutputWaiter.mjs

View workflow job for this annotation

GitHub Actions / main

'statusMessage' is not defined
if (set) {
this.set(inputNum);

// Restore selection if it was set
if (outputElement && selectionStart !== null && selectionEnd !== null) {
requestAnimationFrame(() => {
outputElement.selectionStart = selectionStart;
outputElement.selectionEnd = selectionEnd;
});
}
}
}

/**
Expand Down
Loading