Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all 97500 articles
Browse latest View live

How do I get Visual Studio Code to trust our self-signed proxy certificate?

$
0
0

Our corporate firewall/proxy is keeping VS Code from being able to install extensions because Code doesn't trust something in the chain. It doesn't reliably give an error, but when it does, it's this: "self signed certificate in certificate chain".

This seems like it's an OpenSSL error, but I don't have enough familiarity with OpenSSL to know how to trust the certificate?


Visual Studio Code

$
0
0

I'am using a new MacBook running on OS X 10.15.3 Catalina from scratch. I was/am installing from the gitup site, apache2,php and other requirements to finally install Magento 2.3.3. I am trying to download Visual Studio Code for MacOs. How can I drag the file to applications from downloads folder? I copy paste it to applications and after I wanted to open it and I got this error: “Visual Studio Code” can’t be opened because Apple cannot check it for malicious software. also it said This software needs to be updated. Contact the developer for more information. Safari downloaded this file today at 15:29 from az764295.vo.msecnd.net.

Visual Studio Code - Include context in search results

$
0
0

Is there a way to show context for search results in Visual Studio Code?

By default, if I search "debug" for example I might get 2 lines of code returned.

filea.rb
  def debug(str)
fileb.js
  function debug(str) {

I want to see what the code is for, say, 3 lines above and below each match.

filea.rb
  def somefunca
    puts "some func a"
  end

  def debug(str)
    puts str.inspect
  end

  def somefuncb

Is it possible to add context like this to the search results?

Use Jython and lint on VScode

$
0
0

I would like to use Pylint to lint Jython code.
Clearly, all Java functions (JPanel, JFrame, JComboBox, etc.) are recognized as an error (eg. undefined variable 'JPanel'). I would like to know if there was a way to disable the undefined variable rule on VScode.

Or better yet, if an external Jython linter existed, it would be optimal! Because I have seen that there are no extensions for VSCode for Jython, unfortunately, and of course not even on the linting of jython code.

If none of the things listed above were possible, I would be happy to use another editor with linting, shorcut for self-formatting, etc. In short, the essential of VScode!

EDIT

Based on a small experience of development in Angular it would be optimal to be able to put a pylinting file of Python 2.7 (since jython 3 doesn't exist) inside the project folder, exactly at the same way as it is done with tslint.json, and customize it by excluding for example the java functions.

I hope there is a way to do it.

Is there any way to sync my Visual Studio Code settings between instances?

$
0
0

I'd like to be able to sync my VS Code user settings (File > Preferences > User Settings) to the cloud somehow so I can easily share them between multiple installations, as in Windows 10 and Visual Studio.

Is there a supported way of doing this? Direct support in Code would be great, but otherwise being able to move my settings.json location to a Dropbox or OneDrive folder would work too.

I'm looking specifically for a way of doing this automatically and silently. Manually exporting/importing is too cumbersome and isn't what I'm looking for.


Update: there's a feature request for this here. If you want this feature, please give it a thumbs up.

Settings from the .editorconfig are not respected in Omnisharp / VS Code

$
0
0

I'm trying to set up my Visual Stuido Code so that Omnisharp uses settings supplied in an .editorconfig, as described in https://www.strathweb.com/2019/07/editorconfig-support-in-omnisharp-and-c-extension-vs-code/. I set up a new .net-core 3.1 console project using dotnet new console and added a .editorconfig file to the root of the project. Then I filled in the exact values from the blog post (see below) and enabled editorconfig and roslyn analyzers for OmniSharp. I even tried both methods for enabling the features: In settings.json and in omnisharp.json. But when I used the refactoring capabilities of OmniSharp to create a field from a constructor parameter the generated name was equal to the parameter name instead of being prefixed with _. Restarting the OmniSharp server multiple times didn't help as well.

.editorconfig

[*.cs]
dotnet_style_qualification_for_field = false
dotnet_naming_style.instance_field_style.capitalization = camel_case
dotnet_naming_style.instance_field_style.required_prefix = _

Sample class with auto-generated field

public class MyClass
{
    private readonly string a;  // This should have been named _a

    public MyClass(string a)
    {
        this.a = a;  // Should be without the this.-prefix
    }
}

What I am using:

  • VS Code version 1.42.1
  • C# extension for VS Code version 1.21.12
  • Omnisharp server (part of the extension) version 1.34.13

I would appreciate it alot if anyone could tell me what I am doing wrong or point me in the right direction.

Opening VS Code remote with URLs

$
0
0

Open a file works fine for local sessions.
Like vscode://file/c:/myProject/package.json:5:10 for a local file, from a local browser.
or vscode://file/home/myhome/myProject/package.json:5:10 for a remote file, on a remote server from a browser on the server.

But how about syntax for a vs-code remote ssh session ?

Change color of characters surrounding comments in VS Code


How to change VisualStudioCode comment color with it's slashes?

$
0
0

I added this code to my setting.json

"editor.tokenColorCustomizations": {
    "comments": "#00ff00"
}

But It doesn't change the color for slashes as you can see the below screenshot.
It remains still grayed.

How can I change the whole comment color contains slashes?

enter image description here

C# Error CS0234 even after adding aspnetcore and extensions packages

$
0
0

I have a C# code that I am trying to run on VS Code. The steps I went through are as follows:

  1. create folder (for this case we will name it "Program") for the program files and then run

dotnet new console

  1. Replace the Program.cs file inside the "Program" folder with the Program.cs file I intend to run ( I did this with earlier C# applications and it worked)

  2. Run the following commands to add packages:

dotnet add package aspnetcore

dotnet add package extensions

All packages above were installed successfully

  1. I ran the command

dotnet build

but received the following errors:

error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Please tell me how I am to resolve this issue. Thank you

How to inspect javascript source code using VSCode

$
0
0

Whenever I try to look at javascript method definitions like Math.max() for example, I'll usually end up in a .d.ts file and I don't know where to go from there to view the actual method implementation.

Thanks in advance for the help.

Problem to get vscode to debug jest tests in a typescript environment

$
0
0

I need help with getting vscode debug jest tests in a typescript environment. I compile my project by using a tsconfig file called tsconfig.debug.json and i compile my code like so:

./node_modules/.bin/tsc -p tsconfig.debug.json

The contents of this config file is:

{
  "compilerOptions": {
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "react",
    "outDir": "out",
    "sourceMap": true
  },
  "include": [
    "src"
  ]
}

I have a launch.json that looks like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "name": "vscode-jest-tests",
      "request": "launch",
      "args": ["--runInBand"],
      "cwd": "${workspaceFolder}",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "outFiles": ["out/**/*.js"]
    }
  ]
}

I can launch jest. I can set break points at which the debugger stops. But I cannot step my program. If I try I seem step in random pieces of jest code.

What am I doing wrong?

I have used a recent typescript adaption of create-react-app to create my project.

VS Code not recognising module aliases in Expo project

$
0
0

I've set up import aliases in my Expo project. It's compiling fine however VS Code doenst recognise the import:

In tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "jsx": "react-native",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "noEmit": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "baseUrl": "./",
    "paths": {
      "home": ["./"]
    }
  }
}

In babel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      [
        "module-resolver",
        {
          alias: {
            home: "./"
          }
        }
      ]
    ]
  };
};

The import in the file works: import Thing from "home/src/thing";

I thought this would make VS Code aware of the alias but it appears not to do anything

In jsconfig.json:

{
  "compilerOptions": {
    "target": "es2017",
    "allowSyntheticDefaultImports": false,
    "baseUrl": "./",
    "paths": {
      "home/*": ["./*"]
    }
  },
  "exclude": ["node_modules", "dist"]
}

Debug Jest tests for Lerna project in VS Code

$
0
0

I'm wanting to debug specific Jest tests in VS code for a project that uses Lerna, so there are multiple folders each with their own node_modules folder. With help from this answer I've got the following launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Jest watch",
      "program": "${workspaceRoot}/my/specific/module/node_modules/jest/bin/jest.js",
      "args": ["--verbose", "-i", "--no-cache", "--watchAll"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "cwd": "${workspaceFolder}/my/specific/module"
    }
  ]
}

The problem is that I've had to put the specific path to the module in the launch config so I have to change it every time I want to debug something else.

Is there a better way to do this? Maybe use the folder that's selected in the Explorer? Maybe have some way of launching debug by right-clicking the test file?

How to compare a file in two different commits using the GUI

$
0
0

I refer to https://code.visualstudio.com/Docs/editor/versioncontrol#_viewing-diffs.

Is there a way to easily show a side-by-side diff of a file in two different locations, eg work tree and a specific commit, using the Code GUI?

In Source Control view, if I click on a changed file, it shows a side-by-side diff of the work tree version and (I believe) the latest commit version. Is there a way to easily select another commit?


How to not group folders and files in the sidebar of VS Code but order everything alphabetically?

$
0
0

I have the following file structure in VS Code:

├── 01-getting-started
│   ├── 01-quickstart.mdx
│   ├── 02-setup-prisma
│   │   ├── 01-add-to-an-existing-project.mdx
│   │   ├── 02-start-from-scratch-sql-migrations.mdx
│   │   ├── 03-start-from-scratch-prisma-migrate.mdx
│   │   └── index.mdx
│   ├── 03-tutorial.mdx
│   └── index.mdx

This is how the files are getting rendered in the VS Code sidebar:

enter image description here

There's an issue because the 02-setup-prisma folder alphabetically comes after the 01-quickstart.mdx file but because folders are displayed before files, the alphabetical order of sidebar items isn't retained.

Is it possible to make it so that the alphabetical order of sidebar items is retained, even though that would mix files and folders?

Visual Studio Code to use node version specified by NVM

$
0
0

Is it possible for VS Code to use node version specified by NVM?

I have 6.9.2 installed locally. Even after switching to another version, from the OS X terminal (not the VS Code terminal), restarting VS Code, VS Code still shows using 6.9.2.

OS X terminal

MacBook-Pro-3:~ mac$ node -v
v7.8.0

VS Code Terminal

MacBook-Pro-3:QB-Invoice-API mac$ node -v
v6.9.2

how to import mjs in vscode?

$
0
0

Is it possible to make a vscode extension made of mjs files?

because I tried to make an extension with mjs files only, in order to have full es6 features without TypeScript. But it does not run:

If I make the extension with $ vsce package it does not give any error but it makes an extension that does not work when installed: the contributions that I've put in the package.json are present but vscode shows an error popup that says

Activating extension 'my.ext' failed: Must use import to load ES Module: c:\vsext\extension.mjs.

and every command I try to run gives an error

command 'my.cmd' not found

If I run the extension on the debugger, and the breakpoint on uncaught exception option flagged, it breaks on /src/vs/workbench/api/node/extHostExtensionService.ts:88.

After further search, I noticed that this exception in generatend when the script tries to load the first mjs module.

there is something I can do in order to include my mjs library files?

I think that this behaviour could also impact the use of npm modules with mjs files.


EDIT

Found (kind of) a way using esm:

The idea is to use esm to handle es6 imports and share the vscode object between imported modules

this could seem quite tricky but when I tried to just import * as vscode from "vscode" im my mjs files, vscode complained that can't find module vscode.

so I've done the following

  • add 'esm' as dependency
  • in all the files where vscode is used, remove the import of vscode and add something like this function
var vscode; // will store vscode obj
export function IMPORTVSCODE(vscodeInstance){
    vscode = vscodeInstance
}
  • create a init file where you require vscode (with node native require) and your main module (with esm require)
  • in the init file call main.IMPORTVSCODE(vscode)
  • on all the files A that imports a file B that need vscode, before use the exported stuff from file B, call B.IMPORTVSCODE(vscode)

for example

// init.js
const vscode = require("vscode")
const esm = require("esm")(module/*, options*/)
const main = esm("./main.mjs")
main.IMPORTVSCODE(vscode)
module.exports = main

// main.js
import * as other from "./other.mjs"
var vscode; // will store vscode obj
export function IMPORTVSCODE(vscodeInstance){
    vscode = vscodeInstance
}
function activate(){
  other.IMPORTVSCODE(vscode)
  other.methodThatNeedsVscode()
}

// other.mjs
var vscode; // will store vscode obj
export function IMPORTVSCODE(vscodeInstance){
    vscode = vscodeInstance
}
export function methodThatNeedsVscode(){
    vscode // ...use vscode
}

My extension runs fine now!

But I think that better ideas could be found, so if somebody has some finest solutions, please share them

Git history as regular files

$
0
0

I wonder if there is a way in Git itself, or in a text editor, to have Git history displayed as regular files directly in the file tree.

Like if I have a file landing.html with a couple of previous commits, I want to have the full landind.html.old.v0, landind.html.old.v1, landind.html.old.v2, etc. history files directly next to the current file. With maybe the commit message in the file name as well. Like landind.html.old.v0.initial-commit.

Can this be done in Git itself by adding an hook to after-commit? Or, maybe as an extension to a text editor? I use mainly VSCode, and Sublime. I want to avoid to use an additional tool like gitk.

VS Code is not showing errors

$
0
0

If I have typed:

  var alien1=new AlieNNConstructor("Venus","1511"); instead of var alien1=new AlienConstructor("Venus","1511");

Why does Visual Studio Code does not give me an error. I have experience with Visual Studio and it gives a messege in the error list whenever the code has minor error like non-existing function. I my case the right function is:

function AlienConstructor (alienPlanet1, alienShip1)
  {
      this.alienPlanet=alienPlanet1;
      this.alienShip=alienShip1;
  }
 var alien1=new AlienConstructor("Venus","1511");

Why does not VS Code give me an error if I have typed non-existing function like this:

function AlienConstructor (alienPlanet1, alienShip1)
  {
      this.alienPlanet=alienPlanet1;
      this.alienShip=alienShip1;
  }
 var alien1=new AlieNNConstructor("Venus","1511");

and AlieNNConstructor(alienPlanet1, alienShip1) does not exist anywhere! Why does not VS Code give an error??? The just stops working and it's quite strange. Can I add something like error box to VS Code that is working right?

Viewing all 97500 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>