VSCode 添加随机百分比

VSCode adds random percentage

每次我使用终端打印字符串或任何类型的字符时,它都会自动在每行末尾打印一个“%”。每次我尝试从 C++ 或 php 打印一些东西时都会发生这种情况,还没有尝试过其他语言。我认为它可能与 vscode 有关,但不知道它是怎么来的或如何修复它。

#include <iostream>

using namespace std;

int test = 2;

int main()
{
    if(test < 9999){
        test = 1;
    }

    cout << test;
}

输出:

musti@my-mbp clus % g++ main.cpp -o tests && ./tests
1%                    

还将 cout 从 cout << test; 更改为 cout << test << endl; 从输出中删除 %。

您在使用 zsh 吗?没有 endl 的行被认为是“部分行”,因此 zsh 显示颜色反转的 % 然后转到下一行。

When a partial line is preserved, by default you will see an inverse+bold character at the end of the partial line: a ‘%’ for a normal user or a ‘#’ for root. If set, the shell parameter PROMPT_EOL_MARK can be used to customize how the end of partial lines are shown.

更多信息可在他们的 docs 中找到。