Ah... realised my code snippet was ambiguous. You are right that getAppliedStyles does handle a collapsed cursor... I'm actually meaning the non-collapsed range will cause the character inconsistency. So the guard I was referring to should actually be:

if (cursor.getSelectedRange().collapsed === false) { return operations; } // Cursor has range selection, which causes the character style to be difficult to detect. Skipping this edge case.