microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 449 forks source link

Use "OUTPUT" for the "Compile Active File" task #4012

Open ujos opened 1 month ago

ujos commented 1 month ago

Feature Request

Could you change the "Compile Active File" task (the button at the top-right of the opened C++ file) to report the g++ output to the OUTPUT tab rather than to TERMINAL?

The reason is because it is inconvenient to navigate upon the errors and warnings inside the TERMINAL tab. Home and End buttons actually move the cursor to the begin/end of the command line at the bottom of the tab rather than scroll the compilation output top/down. And PgUp/PgDown also do not scroll up/down.

PS. Previously I posted this issue to VS Code. They say it has to be moved here. Please excuse me if that is the wrong place again. I just do not know which plugin created the "Compile Active File" button.

bobbrow commented 1 month ago

@ujos I just commented on your issue in the vscode repo. The short answer is that I don't think we can redirect output from the tasks to go to the OUTPUT tab unless VS Code added a feature to do that. However, they had a good point that you should be able to see the warnings and errors in the PROBLEMS tab. Does that feature work for you?

ujos commented 1 month ago

@bobbrow Sometimes the PROBLEMS tab is missing the errors and the OUTPUT/TERMINAL is only the option to find the reason of the compiler error. Maybe that is because the output text from the compiler in the TERMINAL tab is too long. Maybe that is another issue, not related to this one.

ujos commented 1 month ago

Please try to put this code into the text editor and press "Compile Active File"

#include<bits/stdc++.h>

template<typename S>
void foo(S& s)
{
    s << s;
}

int main()
{
    std::stringstream ss;
    foo(ss);
}
bobbrow commented 1 month ago

Thanks for the code snippet. I misread your initial report and assumed that you were using the "Build and Debug" button, not the "Compile Active File" button (which is owned by CMake Tools). Using the "Build and Debug" button, I do see problems being added to the PROBLEMS tab, but with "Compile Active File", I do not. I'm moving this issue over to CMake Tools for them to take a look.

ujos commented 1 month ago

Thank you @bobbrow very much for assistance

Evelyn-001 commented 1 month ago

Thanks for reporting this issue. With "Compile Active File", g++ output to the TERMINAL tab now. Our development team will investigate this issue further. We will get back to you if there is any update. Thank you for your support. video082802

ujos commented 1 month ago

@Evelyn-001 I have to add that I'm running VS Code on Linux. Looks like Visual Studio does not have bits/stdc++.h

Another option is to replace that include with the following. Please ensure you have a /Zc:__cplusplus parameter enabled.

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cuchar>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#if __cplusplus >= 201703L
#include <any>
#include <charconv>
// #include <execution>
#include <filesystem>
#include <optional>
#include <memory_resource>
#include <string_view>
#include <variant>
#endif

#if __cplusplus >= 202002L
#include <barrier>
#include <bit>
#include <compare>
#include <concepts>
#if __cpp_impl_coroutine
# include <coroutine>
#endif
#include <latch>
#include <numbers>
#include <ranges>
#include <span>
#include <stop_token>
#include <semaphore>
#include <source_location>
#include <syncstream>
#include <version>
#endif

#if __cplusplus > 202002L
#include <expected>
#include <spanstream>
#if __has_include(<stacktrace>)
# include <stacktrace>
#endif
#include <stdatomic.h>
#endif
Evelyn-001 commented 1 month ago

@ujos , thanks for your reply. We just reproduced the problem of g++ output to TERMINAL tab in "Compile Active File" with your code. This problem can also be reproduced with simple code. Thanks. video082903

ujos commented 1 month ago

@Evelyn-001 The output to TERMINAL is a part of the problem. Another problem is that VSCode is unable to catch the error message (so it does not appear in the PROBLEMS tab) if message is too long. Try to compile the code I posted above with the "Compile Active File" button.

Evelyn-001 commented 4 weeks ago

@ujos, could you please share us a video for your clear repro steps in order to investigate that issue further? We are looking forward to hearing from you. Thanks.

ujos commented 4 weeks ago
[Window Title]
Visual Studio Code

[Main Instruction]
Visual Studio Code

[Content]

Version: 1.92.2 (system setup)
Commit: fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
Date: 2024-08-14T17:29:30.058Z (2 wks ago)
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.19045

[Copy] [OK]

https://github.com/user-attachments/assets/7e2fe5bf-4a4e-4ab4-b79c-92a766438fe9

v-frankwang commented 4 weeks ago

@gcampbell-msft User's question: 1.User wants the compilation result to be displayed in the output window, is this a feature request? 2.User feels that the errors inside the compilation result should be displayed in the PROBLEMS window, I am not sure if this is a bug, can you give some suggestions? If it is a bug I will remind the user to create a new issue to track the this problem.

image

gcampbell-msft commented 4 weeks ago

@v-frankwang My reading of this is that it's a feature request. Thanks.