mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
12 lines
503 B
TypeScript
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;
|