fix 'Maximum call stack size exceeded'
This commit is contained in:
parent
70be560a7a
commit
016315afbc
2 changed files with 13 additions and 3 deletions
|
|
@ -339,8 +339,13 @@ export function uniqsortr(a) {
|
||||||
|
|
||||||
export function unicodeToBase64(text) {
|
export function unicodeToBase64(text) {
|
||||||
const utf8Bytes = new TextEncoder().encode(text);
|
const utf8Bytes = new TextEncoder().encode(text);
|
||||||
const base64String = btoa(String.fromCharCode(...utf8Bytes));
|
let binaryString = '';
|
||||||
return base64String;
|
const chunkSize = 0x8000;
|
||||||
|
for (let i = 0; i < utf8Bytes.length; i += chunkSize) {
|
||||||
|
const chunk = utf8Bytes.subarray(i, i + chunkSize);
|
||||||
|
binaryString += String.fromCharCode.apply(null, chunk);
|
||||||
|
}
|
||||||
|
return btoa(binaryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function base64ToUnicode(base64String) {
|
export function base64ToUnicode(base64String) {
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,12 @@ export function useReplContext() {
|
||||||
// Get the full buffer content from the editor instead of just the evaluated block
|
// Get the full buffer content from the editor instead of just the evaluated block
|
||||||
const fullBufferCode = editorRef.current?.code || code;
|
const fullBufferCode = editorRef.current?.code || code;
|
||||||
setLatestCode(fullBufferCode);
|
setLatestCode(fullBufferCode);
|
||||||
window.location.hash = '#' + code2hash(fullBufferCode);
|
|
||||||
|
try {
|
||||||
|
window.location.hash = '#' + code2hash(fullBufferCode);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('[useReplContext] Failed to update hash:', e.message);
|
||||||
|
}
|
||||||
setDocumentTitle(fullBufferCode);
|
setDocumentTitle(fullBufferCode);
|
||||||
const viewingPatternData = getViewingPatternData();
|
const viewingPatternData = getViewingPatternData();
|
||||||
setVersionDefaultsFrom(fullBufferCode);
|
setVersionDefaultsFrom(fullBufferCode);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue