Skip to content

Commit

Permalink
feat: getAllFormat support undefined include
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Jan 24, 2025
1 parent 9a43a0c commit e950578
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Selection {
return this.getAllFormat(key)[0];
}

getAllFormat(key: string): any {
getAllFormat(key: string, includeUndefined?: boolean): any {
const valSet = new Set();
const minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx);
const maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
Expand All @@ -114,7 +114,11 @@ class Selection {
}
for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
const val = this._getFormat(key, i);
val && valSet.add(val);
if (includeUndefined) {
valSet.add(val);
} else {
val !== undefined && valSet.add(val);
}
}
return Array.from(valSet.values());
}
Expand Down

0 comments on commit e950578

Please sign in to comment.