2026-08-27 12:56:56 +08:00
|
|
|
export const MAX_OPEN_FILE_LINES = 20_000;
|
2026-03-03 18:35:03 +02:00
|
|
|
|
|
|
|
|
export const countLinesWithLimit = (content: string, limit: number): number => {
|
|
|
|
|
if (!content) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let lines = 1;
|
|
|
|
|
for (let index = 0; index < content.length; index += 1) {
|
|
|
|
|
if (content.charCodeAt(index) === 10) {
|
|
|
|
|
lines += 1;
|
|
|
|
|
if (lines > limit) {
|
|
|
|
|
return lines;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
|
};
|