INNER CODE UNIT · JavaScript
collectDedentEdits
tradingview/lightweight-charts · website/plugins/docs-markdown/index.js:480
function collectDedentEdits(ctx, from, to, nestedFrom) {
const nested = ctx.edits.slice(nestedFrom);
const isClaimed = (/** @type {number} */ offset) =>
nested.some((/** @type {Edit} */ edit) => offset >= edit.start && offset < edit.end);
/** @type {number[]} */
const lineStarts = [];
let common = Number.MAX_SAFE_INTEGER;
let newline = ctx.source.indexOf('\n', from);
while (newline !== -1 && newline + 1 < to) {
const lineStart = newline + 1;
const indent = measureIndent(ctx.source, lineStart, to);
if (indent !== null && !isClaimed(lineStart)) {
lineStarts.push(lineStart);
common = Math.min(common, indent);
}
newline = ctx.source.indexOf('\n', lineStart);
}
if (common === 0 || common === Number.MAX_SAFE_INTEGER) {