frontispiece / apps / frontispiece-editor / src / utils / advance-maximally.ts
advance-maximally.ts
Raw
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

export const advanceMaximally = (inkState) => {
	let shouldKeepAdvancing = true
	while (shouldKeepAdvancing && inkState.canAdvance()) {
		if (inkState.getActiveLine() && inkState.getActiveLine().type === 'command') {
			// if we ended on a command, then the command didn't automatically advance
			// to the next line, so we should stop the sequence here.
			break;
		}
		inkState.advance()
	}
}