1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/editor/CodeMirror/utils/formatting/isIndentationEquivalent.ts

12 lines
503 B
TypeScript

import { EditorState } from '@codemirror/state';
import tabsToSpaces from './tabsToSpaces';
// Returns true iff [a] (an indentation string) is roughly equivalent to [b].
const isIndentationEquivalent = (state: EditorState, a: string, b: string): boolean => {
// Consider sublists to be the same as their parent list if they have the same
// label plus or minus 1 space.
return Math.abs(tabsToSpaces(state, a).length - tabsToSpaces(state, b).length) <= 1;
};
export default isIndentationEquivalent;