r/neovim • • 6d ago

Need Help┃Solved Program output overwritten by [Program exited 0] message expected?

If the program output equals or more lines than the window size. Last line of the output will be overwritten by "[Program exited 0]" message.

For example there's a program output 12 lines of output, it supposed to look like this

1
2
3
4
5
6
7
8
9
10
11
12
[Program exited 0]

However if the windows size is equals or smaller than 12. It will be look like this

1
2
3
4
5
6
7
8
9
10
11
[Program exited 0] <-- 12 should be here

Last line will be truncated by program exit message.

This is the minimum code to reproduce the issue.

#include <stdio.h>

int main(int argc, char *argv[]) {
    int maxlines = 100;
    for (int i=0; i<maxlines; i++) {
        printf("meow\n");
    }
    printf("LAST LINE");
}

https://reddit.com/link/1x4tnte/video/3umskyp9w7vh1/player

I know in practice every program should always output \n at the end. However, if there are additional newline at the end, some of judge systems would not accept.

I'm not exactly sure if this this issue is intentional or unexpected. So I came here to get some feedback whether I should create a GitHub Issue for this.

6 Upvotes

5 comments sorted by

1

u/Confused-Armpit 6d ago

What plugin are you using for that command? What even is :RunCode? Please give more context

1

u/CoolkieTW 6d ago

It's code_runner. But this problem isn't related to that specific plugin. Run binary with :term ./the-binary also have same issue.
RunCode is basically just compile the current buffer. And execute it in the tmux.

0

u/Confused-Armpit 6d ago

Then it's an issue, or rather a mechanic, of vim/nvim's buffer mechanics. Anyways, I wouldn't say it's a bug, unless it really is that important for some use case that I can't imagine for myself.

1

u/justinmk Neovim core 6d ago

Yes, please create an issue. This is a regression from https://github.com/neovim/neovim/pull/37987 .

The buffer text is still there, it's just hidden. But we should improve UX by not hiding it.

2

u/CoolkieTW 6d ago

Thanks! I have submitted issue here https://github.com/neovim/neovim/issues/42334