Fix the streaming newline bug (for real this time I promise)

After actually investigating the cause of the bug instead of duct taping
a fix on, I have produced a better fix. The previous fix caused a bug
where there a newline was *removed* where it shouldn't have been when
undoing and redoing. The reason this bug was happening in the first
place was because some "newline regulation" code was falsely detecting
the output stream as a text chunk, and attempted to remove a newline
from there instead of the actual chunk.
This commit is contained in:
somebody 2022-07-30 21:28:50 -05:00
parent 56783a1257
commit 5d135e091e
1 changed files with 5 additions and 2 deletions

View File

@ -2335,7 +2335,11 @@ $(document).ready(function(){
} else if (!empty_chunks.has(index.toString())) {
// Append at the end
unbindGametext();
var lc = game_text[0].lastChild;
// game_text can contain things other than chunks (stream
// preview), so we use querySelector to get the last chunk.
var lc = game_text[0].querySelector("chunk:last-of-type");
if(lc.tagName === "CHUNK" && lc.lastChild !== null && lc.lastChild.tagName === "BR") {
lc.removeChild(lc.lastChild);
}
@ -2355,7 +2359,6 @@ $(document).ready(function(){
(element[0].nextSibling === null || element[0].nextSibling.nodeType !== 1 || element[0].nextSibling.tagName !== "CHUNK")
&& element[0].previousSibling !== null
&& element[0].previousSibling.tagName === "CHUNK"
&& !$("#setoutputstreaming")[0].checked
) {
element[0].previousSibling.appendChild(document.createElement("br"));
}