โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

VSCode extension api - How can I get the files list importing the current active file?

Say there is an active file. If I run the command, I wish all the files that are importing the currently active file are shown on the console.

The active file is not always being imported by its absolute path, but can be a relative path.

For example

// hello.js
export const hello = () => 'world'
// importing-file-{n}.js
import {hello} from '/my/absolute/path';
// or
import {hello} from '../hello.js';
// or (and so on)
import {hello} from '../../hello.js';

The first step I want to achieve is when I run the command, I wish that all the files importing hello.js are printed.

importing-file-1.js
importing-file-2.js
...

How can I do that?

JSDOC Reference key of other type

How does one reference the key of another object within a @type or @typedef?

/**
 * @typedef {{name: {name: string}}} moo
 * @typedef {{name: moo.name}} moo2
 */

I would expect vscode to resolve moo2 as having structure {name: {name: string}}, but it does not.

VSCode, There is no "\n" for the mouse over the function

IN VSCode, I used the Doxygen Generator Documentation plug-in to generate the following comments in a functional method. enter image description here

But when I hovered over the function, there was no newline in the function tip about brief enter image description here

This makes me very uncomfortable.This makes me very uncomfortable.

In addition,I'm not sure if Breif is the problem

enter image description here

enter image description here

enter image description here

enter image description here

Hope how to correct this phenomenon

How to solve the code 1 indicating that the function ".vsc.browser" cannot be found?

Running an R script line by line in VSCode the way I have it set up outputs the expected plots. However, if I run the entire script, I get the following code1:

[Running] Rscript "c:\Users\me\Documents\R\Projects\this_file.R"
Error in .vsc.browser(httpgd::hgd_url(history = TRUE), viewer = FALSE) : 
  could not find function ".vsc.browser"
Calls: scatter3D -> initplist -> plot.new -> <Anonymous>
Execution halted

How can I avoid this error message?

It is likely related to including in .Rprofile the following

options(vsc.plot = FALSE, vsc.use_httpgd = FALSE)
options(device = function(...) {
  httpgd::hgd(silent = TRUE)
  .vsc.browser(httpgd::hgd_url(history = TRUE), viewer = FALSE)
})

because it stops outputting an error by changing to

if (interactive() && Sys.getenv("RSTUDIO") == "") {
  Sys.setenv(TERM_PROGRAM = "vscode")
  if ("httpgd" %in% .packages(all.available = TRUE)) {
    options(vsc.plot = FALSE)
    options(device = function(...) {
      httpgd::hgd(silent = TRUE)
      .vsc.browser(httpgd::hgd_url(history = FALSE), viewer = "Beside")
    })
  }
  source(file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R"))
}

as in here.

Unfortunately the plots are no longer sent to the browser.

How to insert snippet code at different lines in a file in vscode?

i configured user snippet for rust by editing rust.json i am unable to find how to insert different code at different location. For example : i have a main function

// Guessing game in rust

fn main() {
    println!("guess a number : ");
    let mut guess = String::new();

    println!("You guessed : {}", guess);
}

now i want to create a snippet which can make it look like

// Guessing game in rust

use std::io::stdin; // this at the top

fn main() {
    println!("guess a number : ");
    let mut guess = String::new();
    stdin().read_line(|).expect(|); // | represents the cursors i want for snippet

    println!("You guessed : {}", guess);
}

These are my existing snippets but i have no clue how to insert code at different line numbers.

{
    "print to console": {
        "prefix": "print",
        "body": [
            "println!($0)"
        ],
        "description": "Prints output to the console"
    },


        "take user input": {
          "prefix": "rsin",
          "body": [
            "use std::io;",
            "",
            "fn main() {",
            "    // Existing code",
            "    stdin().read_line($1).expect($0);",
            "    // Rest of your code goes here",
            "}",
            ""
          ],
          "description": "take user input"
        }
}

but this is not what i want.

Parsing Open Files Stuck in Infinite Loop for C/C++ Tools (IntelliSense)

I am experiencing difficulties with the C/C++ IntelliSense extension on VsCode and have tried virtually every solution on the internet to no avail. In particular, I am stuck on an infinite "infinite parsing loop," which renders all features of C/C++ IntelliSense disabled, including but not limited to coloring text, hovering for definitions (which causes infinite loading), etc.

I am connected to a Linux machine via Remote - SSH.

  • OS and Version: Apple M1 Pro Mac OS Sonoma 14.4.1
  • VS Code Version: 1.88
  • C/C++ Extension Version: Most recent
  • OS of Remote Machine (SSH): Fedora Linux 38 (Server Edition)

Inside my .vscode directory I have two files: c_cpp_properties.json and settings.json which is blank (I have tried adding many configs to this file to no avail). My c_cpp_properties.json file is populated with the following code:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/lib64/ccache/clang",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}

I have attempted many solutions, including removing all other extensions to isolate the bug. I have also deleted the .vscode and .vscode-server directories and .cache etc. Upon opening VSCode again, .vscode-server folder is automatically generated, which is expected. Meanwhile, no IntelliSense features are available.

Here are the Log Diagnostics:


~~~~~~~~~~~~~~~~~**Log Diagnostics**~~~~~~~~~~~~~~~~~~~~~~~~

-------- Diagnostics - 4/25/2024, 6:12:59 PM
Version: 1.19.9
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/accts/ckk25/**"
    ],
    "defines": [],
    "compilerPath": "/usr/lib64/ccache/clang",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/lib64/ccache/clang",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/accts/ckk25/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.19.9.0
Translation Unit Mappings:
[ /home/accts/ckk25/cs223Main/hw5/Island.cpp - source TU]:
[ /home/accts/ckk25/cs223Main/hw7/main.cpp - source TU]:
Translation Unit Configurations:
[ /home/accts/ckk25/cs223Main/hw5/Island.cpp ]:
    Process ID: 708586
    Memory Usage: 79 MB
    Compiler Path: /usr/lib64/ccache/clang
    Includes:
        /usr/include/c++/13
        /usr/include/c++/13/x86_64-redhat-linux
        /usr/include/c++/13/backward
        /usr/lib64/clang/16/include
        /usr/local/include
        /usr/include
    Standard Version: c++17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=160006
[ /home/accts/ckk25/cs223Main/hw7/main.cpp ]:
    Process ID: 708552
    Memory Usage: 104 MB
    Compiler Path: /usr/lib64/ccache/clang
    Includes:
        /usr/include/c++/13
        /usr/include/c++/13/x86_64-redhat-linux
        /usr/include/c++/13/backward
        /usr/lib64/clang/16/include
        /usr/local/include
        /usr/include
    Standard Version: c++17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=160006
Total Memory Usage: 183 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 40666

ADB returned null value when connect to device over wifi vscode

I want to connect to the phone via wifi and debug my code. Until a few days ago, it was connected and I was debugging without problems. But recently it encounters the ADB returned null value error. The connection steps are as follows using ADB Interface for VSCode extension:

  1. ctrl + shift + p and select ADB: Connect to device ip like below: 1

  2. Enable Wireless debugging on phone and type given ip address and press enter: 2

  3. Then type the given port and press enter: 3

after few moments, it supposed to show this massage: Connected to <ip>:<port>, but it shows this message and does not connect to the phone:

4

I also tried another extension called Android ADB WLAN, but the result was the same. what is the problem? how can i solve this?

OpenCV cpp with VS Code on Mac M3

I've just moved to Mac and I'm setting up the environment. However, I have a big problem with the cpp libraries in VS Code that I cannot solve... I've installed opencv with brew, and it finished in opt/homebrew/Cellar/opencv/4.9.0_6/include/opencv4/opencv2, so in this folder I have opencv.hpp In VS Code I setup my c_cpp_properties.json in this way:

{
"configurations": [
    {
        "name": "Mac",
        "includePath": [
            "${workspaceFolder}/**",
            "/opt/homebrew/Cellar/opencv/4.9.0_6/include/opencv4"
            
        ],
        "defines": [],
        "macFrameworkPath": [
            "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
        ],
        "compilerPath": "/opt/homebrew/bin/g++-13",
        "cStandard": "c17",
        "cppStandard": "c++17",
        "intelliSenseMode": "macos-gcc-arm64",
        "configurationProvider": "ms-vscode.cpptools"
    }
],
"version": 4

}

and the tasks.json like this

{
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: g++ build active file",
        "command": "/opt/homebrew/bin/g++-13",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}",
            "-L/opt/homebrew/Cellar/opencv/4.9.0_6/include/opencv4"
        ],
        "options": {
            "cwd": "${fileDirname}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "Task generated by Debugger."
    }
],
"version": "2.0.0"

}

The problem is that when I write in my code #include "opencv2/opencv.hpp" I get this error directly in the editor and during the building 'opencv2/opencv.hpp' file not found gcc [Ln 2, Col 10]. I tried to add / /** /* at the end of the path but nothing changes, while if I import doing other paths I get extra errors saying that the path doesn't exist. Is someone able to help me?

VSCode in WSL: how to sudo a root file so I can edit it

WSL v.1 -- VSCode v1.40.1 (using 'Remote - WSL' extension 40.3)

How to open a root-owned file for edit using sudo and VSCode? (without running as root)

If I open a root file without sudo, I can't edit it (expected): $ code /etc/profile.d/custom-profile.sh $

enter image description here

But, if I try to sudo code the file, I get:

$ sudo code /etc/profile.d/custom-profile.sh
[sudo] password for xxxx:
sudo: code: command not found

Binarify's answer below shows that I can switch the default user to root, but I definitely don't want to be running as root, so I'm still looking for another solution.

Why do I get a "ModuleNotFoundError" in VS Code despite the fact that I already installed the module?

I'm trying to debug some python code using VS Code. I'm getting the following error about a module that I am sure is already installed.

Exception has occurred: ModuleNotFoundError
No module named 'SimpleITK'
  File "C:\Users\Mido\Desktop\ProstateX-project\src\01-preprocessing\03_resample_nifti.py", line 8, in <module>
    import SimpleITK as sitk

I installed the module using

sudo pip install SimpleITK

I know that it was installed because I was getting a similar error when I ran the code through the command line, and it was fixed by doing the above. I don't understand why VS code does not recognize that it's already installed.

Running Python Debugger in VS Code Not Stopping at Breakpoints

I have a python venv and I'm running the following code within VS Code:

text = "hello"
print(text)

I'm trying to break at text = "hello", my launch.json file is:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Debug Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "stopOnEntry": true,
            "justMyCode": false
        },
    ]
}

The VS Code terminal commands are:

c:\Programming\Python\VEnv_Python310\Scripts\python.exe' 'c:\Users\lautry\.vscode\extensions\ms-python.python-2024.2.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '60718' '--' 'C:\Programming\Python\VEnv_Python310\test.py'

The debugger isn't stopping at my breakpoints.

Can't set breakpoint in library, even with justMyCode cleared

I'm running VS Code Version: 1.87.1.

I'm trying to set a breakpoint in a package I've installed into my venv with pip. When I set the breakpoint, it looks like it's set (red dot on the source line), but when I run my test in debug mode, the breakpoint gets cleared with the message:

Breakpoint in file excluded by filters.

Note: may be excluded because of "justMyCode" option (default == true).Try setting "justMyCode": false in the debug configuration (e.g., launch.json).

I do indeed have "debugpy.debugJustMyCode": false, in my settings.json file. I've found the four-year old Breakpoints not getting hit in VSC even with justMyCode = false which sounds like the same problem, but (like the OP in that question), it's not clear how to work around this.

To answer starball's question, I do not have a launch.json file.

How to run bash script within VS Code?

I want to run bash script when I hit F5 and see the results in the terminal like I can do with python scripts or whatever. I tried to do that with Bash Debug however it automatically goes to the debug mode and stops at the first step even if I do not put breakpoint. This is the launch configuration I use.

        {
            "type": "bashdb",
            "request": "launch",
            "name": "Run mysql test",
            "cwd": "${workspaceFolder}",
            "program": "/srv/gpf/dba/mysqlslap/run.sh",
            "args": []
        }
โŒ
โŒ