mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 14:22:52 +00:00
Fix edge case where string was emitting data: twice.
Also, a case where the input is right around 50 chars. It can be truncated twice, leading to a long `.....`
This commit is contained in:
@@ -417,7 +417,7 @@ const CodeEditor = createClass({
|
|||||||
widget : (from, to)=>{
|
widget : (from, to)=>{
|
||||||
let text = '';
|
let text = '';
|
||||||
let currentLine = from.line;
|
let currentLine = from.line;
|
||||||
const maxLength = 50;
|
let maxLength = 50;
|
||||||
|
|
||||||
let foldPreviewText = '';
|
let foldPreviewText = '';
|
||||||
while (currentLine <= to.line && text.length <= maxLength) {
|
while (currentLine <= to.line && text.length <= maxLength) {
|
||||||
@@ -432,23 +432,16 @@ const CodeEditor = createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
text = foldPreviewText || `Lines ${from.line+1}-${to.line+1}`;
|
text = foldPreviewText || `Lines ${from.line+1}-${to.line+1}`;
|
||||||
|
|
||||||
|
|
||||||
text = text.replace('{', '').trim();
|
text = text.replace('{', '').trim();
|
||||||
|
|
||||||
// Extra data url chomping
|
// Truncate data URLs
|
||||||
// Try to make it pretty...
|
const startOfData = text.indexOf('data:');
|
||||||
const startOfData = text.indexOf('data:') > 0 ? text.indexOf('data:') : false;
|
if(startOfData > 0)
|
||||||
if(startOfData) {
|
maxLength = Math.min(startOfData + 5, maxLength);
|
||||||
text = (startOfData > maxLength) ?
|
|
||||||
`${text.slice(0, text.indexOf(':') + 1)} ... ${text.slice(startOfData, startOfData + 5)} ...` :
|
|
||||||
`${text.slice(0, text.indexOf('data:') + 5)} ...`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(text.length > maxLength)
|
if(text.length > maxLength)
|
||||||
text = `${text.slice(0, maxLength)}...`;
|
text = `${text.slice(0, maxLength)}...`;
|
||||||
|
|
||||||
|
|
||||||
return `\u21A4 ${text} \u21A6`;
|
return `\u21A4 ${text} \u21A6`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user