Bug 466961 - Extra line endings in the integrated console output window
Summary: Extra line endings in the integrated console output window
Status: RESOLVED FIXED
Alias: None
Product: krusader
Classification: Applications
Component: general (other bugs)
Version First Reported In: 2.8.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Krusader Bugs Distribution List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-06 18:35 UTC by Igor Mironchik
Modified: 2025-08-14 03:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Screenshot of the console output window (89.53 KB, image/png)
2023-03-06 18:37 UTC, Igor Mironchik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Mironchik 2023-03-06 18:35:29 UTC
SUMMARY
Extra line endings in the integrated console output window


STEPS TO REPRODUCE
1. Run ctest from CMake in build directory with test.

OBSERVED RESULT

I see extra line ending in the output, like:

```
Test project /path/to
      Start  1: test.funcs.qt
 1/10 Test  #1: test.funcs.qt ....................   Passed    0.01 sec
      Start  2: test.funcs.stl
 2/10 Test  #2: test.funcs.stl ...................   Passed    0.00 sec
      Start  3: test.md_parser.qt

 3/10 Test  #3: test.md_parser.qt ................   Passed    0.06 sec

      Start  4: test.md_parser.stl

 4/10 Test  #4: test.md_parser.stl ...............   Passed    0.07 sec

      Start  5: test.md_parser.commonmark.qt

 5/10 Test  #5: test.md_parser.commonmark.qt .....   Passed    0.12 sec

      Start  6: test.md_parser.commonmark.stl

 6/10 Test  #6: test.md_parser.commonmark.stl ....   Passed    0.15 sec

      Start  7: test.md_parser.gfm.qt

 7/10 Test  #7: test.md_parser.gfm.qt ............   Passed    0.01 sec

      Start  8: test.md_parser.gfm.stl

 8/10 Test  #8: test.md_parser.gfm.stl ...........   Passed    0.01 sec

      Start  9: test.internal_string.qt

 9/10 Test  #9: test.internal_string.qt ..........   Passed    0.01 sec

      Start 10: test.internal_string.stl

10/10 Test #10: test.internal_string.stl .........   Passed    0.00 sec

100% tests passed, 0 tests failed out of 10

Total Test time (real) =   0.44 sec
```


EXPECTED RESULT

In the standard console I see text like:

```
Test project /path/to
      Start  1: test.funcs.qt
 1/10 Test  #1: test.funcs.qt ....................   Passed    0.01 sec
      Start  2: test.funcs.stl
 2/10 Test  #2: test.funcs.stl ...................   Passed    0.00 sec
      Start  3: test.md_parser.qt
 3/10 Test  #3: test.md_parser.qt ................   Passed    0.04 sec
      Start  4: test.md_parser.stl
 4/10 Test  #4: test.md_parser.stl ...............   Passed    0.05 sec
      Start  5: test.md_parser.commonmark.qt
 5/10 Test  #5: test.md_parser.commonmark.qt .....   Passed    0.11 sec
      Start  6: test.md_parser.commonmark.stl
 6/10 Test  #6: test.md_parser.commonmark.stl ....   Passed    0.15 sec
      Start  7: test.md_parser.gfm.qt
 7/10 Test  #7: test.md_parser.gfm.qt ............   Passed    0.01 sec
      Start  8: test.md_parser.gfm.stl
 8/10 Test  #8: test.md_parser.gfm.stl ...........   Passed    0.01 sec
      Start  9: test.internal_string.qt
 9/10 Test  #9: test.internal_string.qt ..........   Passed    0.00 sec
      Start 10: test.internal_string.stl
10/10 Test #10: test.internal_string.stl .........   Passed    0.00 sec

100% tests passed, 0 tests failed out of 10

Total Test time (real) =   0.39 sec
```


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma:  Kubuntu 22.04 LTS
(available in About System)
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.3
Comment 1 Igor Mironchik 2023-03-06 18:37:42 UTC
Created attachment 157055 [details]
Screenshot of the console output window
Comment 2 Alex Bikadorov 2024-12-07 14:28:43 UTC
To clarify: The output window is the result if a user action with execution mode "Collect output" is activated.

I could reproduce this with current master version. I guess cmake is adding some control characters to the output which are displayed as newline in the output.
Comment 3 Igor Mironchik 2025-07-05 05:21:59 UTC
Hi. I investigated this question a little. Look, you collect data from process in:

void KrActionProc::addStdout()
{
    if (_output) {
        _output->addStdout(QString::fromLocal8Bit(_proc->readAllStandardOutput().data()));
    }
}

I.e. you do readAllStandardOutput(). And this method always ends data with "\n", even if process didn't write "\n". At least on Linux it's so.

In other words consecutive calls KrActionProc::addStdout() will add extra "\n" after each call. This is the root of the problem.

Fix seems quite simple, but I'm not sure. Looks like all is needed to remove the last "\n" in each readAllStandardOutput().
Comment 4 Igor Mironchik 2025-07-05 13:34:03 UTC
I'm wrong in prev. comment... Investigating.
Comment 5 Bug Janitor Service 2025-07-05 13:51:29 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/krusader/-/merge_requests/170
Comment 6 Igor Mironchik 2025-08-14 03:45:11 UTC
Git commit 34a01dbe6502cf5e00e7e56ed36315a30f5a82cd by Igor Mironchik.
Committed on 14/08/2025 at 03:41.
Pushed by imironchik into branch 'master'.

Fix extra lines in integrated console output window.

M  +3    -3    app/UserAction/kraction.cpp

https://invent.kde.org/utilities/krusader/-/commit/34a01dbe6502cf5e00e7e56ed36315a30f5a82cd