Merge pull request #23724 from ttencate/get_total_character_count_23720
Fix return value of get_total_character_count
This commit is contained in:
commit
35aa3301d7
|
@ -30,7 +30,7 @@
|
||||||
<return type="int">
|
<return type="int">
|
||||||
</return>
|
</return>
|
||||||
<description>
|
<description>
|
||||||
Returns the total length of the text.
|
Returns the total number of printable characters in the text (excluding spaces and newlines).
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_visible_line_count" qualifiers="const">
|
<method name="get_visible_line_count" qualifiers="const">
|
||||||
|
|
|
@ -393,7 +393,7 @@ void Label::regenerate_word_cache() {
|
||||||
|
|
||||||
WordCache *last = NULL;
|
WordCache *last = NULL;
|
||||||
|
|
||||||
for (int i = 0; i < xl_text.size() + 1; i++) {
|
for (int i = 0; i <= xl_text.length(); i++) {
|
||||||
|
|
||||||
CharType current = i < xl_text.length() ? xl_text[i] : ' '; //always a space at the end, so the algo works
|
CharType current = i < xl_text.length() ? xl_text[i] : ' '; //always a space at the end, so the algo works
|
||||||
|
|
||||||
|
@ -429,12 +429,11 @@ void Label::regenerate_word_cache() {
|
||||||
|
|
||||||
if (current == '\n') {
|
if (current == '\n') {
|
||||||
insert_newline = true;
|
insert_newline = true;
|
||||||
} else {
|
} else if (current != ' ') {
|
||||||
total_char_cache++;
|
total_char_cache++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < xl_text.length() && xl_text[i] == ' ') {
|
if (i < xl_text.length() && xl_text[i] == ' ') {
|
||||||
total_char_cache--; // do not count spaces
|
|
||||||
if (line_width > 0 || last == NULL || last->char_pos != WordCache::CHAR_WRAPLINE) {
|
if (line_width > 0 || last == NULL || last->char_pos != WordCache::CHAR_WRAPLINE) {
|
||||||
space_count++;
|
space_count++;
|
||||||
line_width += space_width;
|
line_width += space_width;
|
||||||
|
|
Loading…
Reference in New Issue