https://bugs.kde.org/show_bug.cgi?id=520257

            Bug ID: 520257
           Summary: Status Bar Character Count Excludes Newlines
    Classification: Applications
           Product: kate
      Version First 23.08.5
       Reported In:
          Platform: Ubuntu
                OS: Linux
            Status: REPORTED
          Severity: minor
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 192362
  --> https://bugs.kde.org/attachment.cgi?id=192362&action=edit
Screenshot demonstrating the bug: Kate counts 'sus' and 'fr' as 5 characters,
whereas wc -m counts them as 7 (including newlines).

# DESCRIPTION
The character count feature in the status bar (enabled via "Show word count")
excludes line ending characters (newlines) from the total count. This results
in a count that is lower than the actual file size, which is problematic for
users who need to adhere to strict character limits in form fields or web
interfaces where every character, including newlines, counts against the limit.

# STEPS TO REPRODUCE
1. Open Kate.
2. Right-click the status bar and enable "Show word count" (which enables
character counting).
3. Create a text file with the following content:

```
sus
fr
```

4. Observe the character count displayed in the status bar for this selection
or the whole document.
5. Save file as ohio.txt
6. Open a terminal and run `wc -m ohio.txt` on the same file.
7. Compare the two numbers.


# OBSERVED RESULT
Kate displays a character count that excludes the line ending characters. For
example, in the test case above, Kate may count only the visible letters (5
characters), whereas `wc -m` includes the newlines and reports a higher count
(6 or 7 characters if "Append newline at end of file on save" is enabled in
settings > Open/Save). Currently, there is no configuration option to display
line ending characters or include them in the status bar count. Significant
discrepancies between Kate's count and standard tools like `wc` have been
observed in files with many lines due to this exclusion (see
https://bugs.kde.org/show_bug.cgi?id=386897#c3).

# EXPECTED RESULT
The character count in the status bar should reflect the exact number of
characters in the document, including line ending characters (e.g., \n).
Alternatively, there should be a configuration option (e.g., "Include line
endings in character count") to toggle this behavior, allowing the count to
match standard utilities like `wc -m`.

# SOFTWARE/OS VERSIONS
```
Operating System: Ubuntu Studio 24.04
KDE Plasma Version: 5.27.12
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13
Kernel Version: 6.8.0-111-lowlatency (64-bit)
Graphics Platform: offscreen
Processors: 24 × AMD Ryzen 9 5900X 12-Core Processor
Memory: 47.0 GiB of RAM
Graphics Processor: AMD Radeon RX 6600 XT
```

# ADDITIONAL INFORMATION
This issue disrupts workflows that require precise character counts for
submission forms (e.g., academic forms, web bios, or database entries). The
only current workaround is to use an external command-line tool like `wc -m`,
which defeats the purpose of having a built-in status bar indicator. Adding
this feature would improve compatibility with standard character counting
expectations across different platforms and tools.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to