You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When javascript code uses backticks, the code can disappear. I've been trying to narrow down what causes it.
I believe it has something to do with long strings in between backticks, or with code being in between two long backtick blocks.
TO REPRODUCE
Paste data from a table into a javascript variable that uses backquotes, so that the backquote variable becomes taller than the textarea.
Paste the below code into the example codemirror instance, replacing the old example code.
Expand the area in between the first two backticks. You can try entering a couple of newlines, but for the best effect select some contents of a long html table and copy that into the variable (at 'paste over me'. The important thing is to make the content longer than the height of the textarea, so it overflows.
Scroll up and down rapidly a few times.
notice strange behaviour, or even a fully white editor. Clicking on it can resolve it, using arror keys can make it worse.
Copy this:
// codemirror issue when scrolling over long backtick variables
// let test = "a normal variable";
let test = `
paste over me
`
async function init_tf() {
console.log("BEAUTY WORKER: LOADING BEAUTY TENSORFLOW MODEL");
const LOCAL_MODEL_PATH = './models/beauty.json';
//const HOSTED_MODEL_PATH = './models/beauty.json';
//let model;
try {
model = await tf.loadLayersModel(LOCAL_MODEL_PATH);
//window.model.summary();
//beauty_detector_ready = true;
postMessage({'loaded':'beauty'});
} catch (err) {
console.log("failed to load beauty scoring model:", err);
//alert("failed to load beauty scoring model");
document.getElementById('debug-log').innerHTML = "Error, beauty worker: failed to load model";
}
}
init_tf();
onmessage = function(incoming) {
//console.log('Message received from main script');
var return_message = null;
if (!model) {
console.log("* no model loaded")
return null;
}
else{
//console.log("onmessage in beauty worker. Model was loaded. incoming data:");
//console.log(incoming)
/*
result = incoming.data;
console.log("incoming result object in web worker:");
console.log(result);
console.log(result.descriptor);
*/
if( 'data' in incoming ){
//console.log("data in incoming beauty prediction");
try{
if( incoming.data.length == 128 ){
//console.log("beauty worker: incoming data was 128 long");
var vector_array = [];
for (var i = 0; i < incoming.data.length; i++) {
vector_array.push( incoming.data[i] );
}
const shape = [1,128];
// Run the normalized array through the model to get a prediction
let result = tf.tidy( () => {
//console.log("predingting BMI now..");
//return model.predict( tf.stack( [ tf.tensor1d( normalized ) ] ) );
var a = tf.tensor(vector_array,shape,'float32');
const prediction = model.predict( a );
return_message = prediction.dataSync();
});
//prediction.dispose();
//let prediction = await result.data();
//console.log("result.data() = " + result.data());
//let prediction = await result.data();
//result.dispose();
//console.log("beauty worker: prediction: " + return_message);
}
else{
console.log("beauty worker: incoming data should be array of 128 floats (face fingerprint)");
}
}
catch(e){
console.log("error: beauty worker: " + e);
}
}
else{
console.log("beauty worker: no data in incoming message");
}
}
//var workerResult = 'Result: ' + (incoming.data[0] * incoming.data[1]);
//console.log('Posting message back to main script');
postMessage(return_message);
}
async function init_tf() {
console.log("BEAUTY WORKER: LOADING BEAUTY TENSORFLOW MODEL");
const LOCAL_MODEL_PATH = './models/beauty.json';
//const HOSTED_MODEL_PATH = './models/beauty.json';
//let model;
try {
model = await tf.loadLayersModel(LOCAL_MODEL_PATH);
//window.model.summary();
//beauty_detector_ready = true;
postMessage({'loaded':'beauty'});
} catch (err) {
console.log("failed to load beauty scoring model:", err);
//alert("failed to load beauty scoring model");
document.getElementById('debug-log').innerHTML = "Error, beauty worker: failed to load model";
}
}
init_tf();
onmessage = function(incoming) {
//console.log('Message received from main script');
var return_message = null;
if (!model) {
console.log("* no model loaded")
return null;
}
else{
//console.log("onmessage in beauty worker. Model was loaded. incoming data:");
//console.log(incoming)
/*
result = incoming.data;
console.log("incoming result object in web worker:");
console.log(result);
console.log(result.descriptor);
*/
if( 'data' in incoming ){
//console.log("data in incoming beauty prediction");
try{
if( incoming.data.length == 128 ){
//console.log("beauty worker: incoming data was 128 long");
var vector_array = [];
for (var i = 0; i < incoming.data.length; i++) {
vector_array.push( incoming.data[i] );
}
const shape = [1,128];
// Run the normalized array through the model to get a prediction
let result = tf.tidy( () => {
//console.log("predingting BMI now..");
//return model.predict( tf.stack( [ tf.tensor1d( normalized ) ] ) );
var a = tf.tensor(vector_array,shape,'float32');
const prediction = model.predict( a );
return_message = prediction.dataSync();
});
//prediction.dispose();
//let prediction = await result.data();
//console.log("result.data() = " + result.data());
//let prediction = await result.data();
//result.dispose();
//console.log("beauty worker: prediction: " + return_message);
}
else{
console.log("beauty worker: incoming data should be array of 128 floats (face fingerprint)");
}
}
catch(e){
console.log("error: beauty worker: " + e);
}
}
else{
console.log("beauty worker: no data in incoming message");
}
}
//var workerResult = 'Result: ' + (incoming.data[0] * incoming.data[1]);
//console.log('Posting message back to main script');
postMessage(return_message);
}
let old_source = `
English Wikipedia English Wikipedia English Latn en 120,580 15 January 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in English
German Wikipedia Deutschsprachige Wikipedia German Latn de 17,398 16 March 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in German
French Wikipedia Wikipédia en français French Latn fr 17,346 23 March 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in French
Spanish Wikipedia Wikipedia en español Spanish Latn es 13,965 20 May 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Spanish
Japanese Wikipedia ウィキペディア日本語版
(Wikipedia nihongo-ban) Japanese Jpan ja 13,879 20 May 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Japanese
Russian Wikipedia Русская Википедия
(Russkaya Vikipediya) Russian Cyrl ru 9,795 20 May 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Russian
Portuguese Wikipedia Wikipédia em português Portuguese Latn pt 8,447 11 May 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Portuguese
Chinese Wikipedia Traditional Chinese: 中文維基百科,
simplified Chinese: 中文维基百科
(pinyin: Zhōngwén wéijī bǎikē) Chinese
(written vernacular Chinese) Hans/Hant zh 7,846 24 October 2002
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Chinese
Italian Wikipedia Wikipedia in italiano Italian Latn it 7,718 11 May 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Italian
Persian Wikipedia ویکیپدیای فارسی
(Vikipediyâ fārsi) Persian Arab fa 5,247 19 December 2003
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Persian
Polish Wikipedia Polskojęzyczna Wikipedia Polish Latn pl 4,348 26 June 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Polish
Arabic Wikipedia ويكيبيديا العربية
(Wīkībīdiyā al-ʿarabiyya) Arabic Arab ar 4,125 8 July 2003
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Arabic
Dutch Wikipedia Nederlandstalige Wikipedia Dutch Latn nl 3,751 19 June 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Dutch
Ukrainian Wikipedia Українська Вікіпедія
(Ukrayinsʹka Vikipediya) Ukrainian Cyrl uk 3,497 30 January 2004
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Ukrainian
Hebrew Wikipedia ויקיפדיה העברית
(Vikipedya ha-ivrit) Hebrew Hebr he 3,135 8 July 2003
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Hebrew
Indonesian Wikipedia Wikipedia bahasa Indonesia Indonesian Latn id 3,069 30 March 2003
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Indonesian
Turkish Wikipedia Türkçe Vikipedi Turkish Latn tr 2,715 5 December 2002
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Turkish
Swedish Wikipedia Svenskspråkiga Wikipedia Swedish Latn sv 2,285 23 May 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Swedish
Czech Wikipedia Česká Wikipedie Czech Latn cs 2,041 3 May 2002
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Czech
Vietnamese Wikipedia Wikipedia tiếng Việt Vietnamese Latn vi 1,918 November 2002 (unknown day)
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Vietnamese
Korean Wikipedia 한국어 위키백과
(Han-gugeo wikibaekgwa) Korean Hang ko 1,805 11 October 2002
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Korean
Finnish Wikipedia Suomenkielinen Wikipedia Finnish Latn fi 1,576 21 February 2002
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Finnish
Hungarian Wikipedia Magyar Wikipédia Hungarian Latn hu 1,536 8 July 2003
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in Hungarian
Simple English Wikipedia Simple English Wikipedia Simple English Latn simple 1,375 18 September 2001
Wikipedia logo showing "Simple English Wikipedia" in English
Hindi Wikipedia हिन्दी विकिपीडिया
(Hindī vikipīḍiyā) Hindi Deva hi 1,207 11 July 2003
`
Browser and platform
MacOS, Both Safari and Brave are affected
Reproduction link
No response
The text was updated successfully, but these errors were encountered:
Attached patch should help. In the end this had nothing to do with template strings or pasting, but your reproduction instructions helped me narrow it down.
Describe the issue
When javascript code uses backticks, the code can disappear. I've been trying to narrow down what causes it.
I believe it has something to do with long strings in between backticks, or with code being in between two long backtick blocks.
TO REPRODUCE
Paste data from a table into a javascript variable that uses backquotes, so that the backquote variable becomes taller than the textarea.
Copy this:
Browser and platform
MacOS, Both Safari and Brave are affected
Reproduction link
No response
The text was updated successfully, but these errors were encountered: