Skip to content

Commit

Permalink
Added function to count characters in input field with emoji.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Feb 27, 2024
1 parent 0c6b2c6 commit 333587d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/widgets/fields/input_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3988,4 +3988,9 @@ void PrepareFormattingOptimization(not_null<QTextDocument*> document) {
}
}

int FieldCharacterCount(not_null<InputField*> field) {
// This method counts emoji properly.
return field->document()->characterCount() - 1;
}

} // namespace Ui
2 changes: 2 additions & 0 deletions ui/widgets/fields/input_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,6 @@ class InputField : public RpWidget {

void PrepareFormattingOptimization(not_null<QTextDocument*> document);

[[nodiscard]] int FieldCharacterCount(not_null<InputField*> field);

} // namespace Ui

0 comments on commit 333587d

Please sign in to comment.