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

Unable to debug an Electron app with Visual Studio Code

$
0
0

I'm just starting to learn Electron/VueJs/NodeJS & Visual Studio Code, so to start I have find an existing project :

https://github.com/Physiix/topsi-project-manager

I follow the instructions and run it, its easy (I use npm instead of yarm, but its the same)

So, I try to debug it with Visual Studio Code, but I cannot find a way !

I have only do a small change in order to run in: 1) in the package.json, I added the following : "main": "./src/renderer/main.js" 2) in the launch.json I don't need the "program" attribute anymore !

Now it run the right .js file, but still I got an error.

enter image description here It seems it does not detect VueJS, right ?

Do you have any idea to fix it, how can I debug my app with headache and configuration switch ? (Because I still need a clear build)

Thx


VSCode: trigger organizeImports when git staging

$
0
0

I like the automated organize feature in VSCode, but having it doing it on every save has given me some trouble.

...
"editor.codeActionsOnSave": {
    "source.organizeImports": true
  },
...

Is it possible to set up some git hooks that organize the imports (either via vscode or some other script/lib) when I stage them?

Issues

If I hit save too early (do it to kick off prettier all the time) before I have used the imported methods - then it removes it and I have to write the import again.

If I break the code (.jsx) and something appears to not be used and I hit save (to trigger prettier), then it removes the imports. I then have to import them again.

Environment path not working in vscode with processing language extension

$
0
0

I am working in processing language extension for VS Code.

I have a problem when building a project, the shell can't find my processing-java file in the path even thought I set it correctly.

Cmd or Powershell on its own can find it no problem and responds correctly. I have a laptop where it also works fine even with VS Code.

So my problem is only based on one machine and definitely within VS Code or the processing language extension. I have tried reinstalling the extension with no help. Restarted the computer. My last hope is to reinstall VS Code, but before that I'd like to ask if any of you have better suggestions.

VS Code - Is there a way you can make the Minimap bigger?

$
0
0

I have enabled the MiniMap in Visual Studio Code (VSCODE) with the following code: "editor.minimap.enabled": true

But can I make it bigger? It's so small at the right.

Textmate grammar - conditionnal multiline match - VS code

$
0
0

I have search the internet and still haven't found a way to do this.

I want to match the keywords (keyword1 = keyword.scope.lang, keyword2 = keyword.scope.props.lang) in the following example:

keyword1 placeholder

keyword1 placeholder
{
keyword2 placeholder
}

I could do a begin with \\bkeyword1\\b and end with \\}, but this would result in breaking the example, because there is a possibility that keyword1 doesn't need a end curly bracket, it can just be keyword1 placeholder (kind of like a forward declaration).

And just to be clear, keyword2 can only be found in between the curly brackets of a keyword1.

Thanks in advance!

Extension: Provide code navigation support for custom script language

$
0
0

I would like to support basic code navigation in my extension for my custom script langauge. Things are not too complicated, a simple regex can actually find where a call or jump occurs and where it goes. VSCode API says: (https://code.visualstudio.com/api/references/vscode-api)

Despite that, features like automatic word-completion, code navigation, or code checking have become popular across different tools for different programming languages.

So I think it should be possible, but I can't find any API for that. I don't yet want to implement a full-blown external language server, but the simpler in-built typescript.

I might misuse the term "code navigation", so under that I mean that if I ctrl+click a variable or function name I can navigate where it is declared.

Is there any API for that?

VS Code Python autopep8 does not honor 2 spaces hanging indentation

$
0
0

I'm trying to get autopep8 work to properly indent Python code with 2 spaces instead of 4. I'm using VS Code with Python extension which uses autopep8 for formatting. I found here that autopep8 can be configured to use 2 spaces by

"python.formatting.autopep8Args": ["--indent-size=2"]

But it does not work for me.

My situation is like this. When I press enter, it correctly starts the next line with the same indentation as the previous line. Press enter after an open parenthesis, it correctly starts the new line with 2 more spaces. But when I paste or save (I have "editor.formatOnPaste" and "editor.formatOnSave" set to true), the annoying thing happened: all the 2-space indentation inside the parentheses became 4 (other 2-space indentation are unaffected). Why is it doing this and how can I make it 2 spaces everywhere?

enter image description here

====EDIT====

I found out that the pylint error Wrong hanging indentation (remove 2 spaces). [bad-continuation]. It's because my pylintrc has indent-after-paren=2. I'm wondering if autopep8 or other Python formatter can set this property?

VSCode: Debug > Add Configuration, nothing happens

$
0
0

Using Visual Studio Code v 1.32.3 on Windows 10, when I navigate to Debug > Add Configuration, nothing happens. No errors or other messages, nothing appears to be written to the workspace folder, no errors in Event Viewer, so far just nothing.

I am somewhat new to VSCode so please don't discount that this might be a newbie error. Potentially notable is that the project is a Cordova project, I have created a Workspace (and confirmed that I am using it and not just opening the folder).

What I have checked so far:

  • Verifying that nothing is actively trying to build or otherwise access that folder. PhoneGap Desktop is stopped and no emulators running.
  • Restarted PC
  • Reinstalled the Cordova Tools plugin

Interestingly if I open a new instance of VS Code and before opening any file or folder I go back to Debug > Add Configuration I will get a message "Please first open a folder in order to do advanced debug configura..." So this indicates that there may be a problem with my workspace or directory but I haven't found it yet.

Any ideas greatly appreciated.

Edit 1:

Version of Cordova Tools is 1.8.0.

I've since tried adding my own launch.json to the .vscode directory. Contents:

{
    "version": "0.2.0",
    "configurations": [
    {
        "name": "Run android on device|emulator",
        "type": "cordova",
        "request": "launch",
        "platform": "android",
        "target": "device|emulator",
        "sourceMaps": true,
        "cwd": "${workspaceFolder}"
    },
    ]
}

Notable is that in the bottom right corner of the window a "Add Configuration" button appears while I am viewing launch.json and it does appear to work correctly, prompting me with snippets to add.

None of these impact my ability to debug unfortunately.


How to get terminal in vs code to wrap code until the edge of the display width?

$
0
0

How to get terminal in vs code to wrap code until the edge of the display width? I want my code in terminal to extend longer than what it is. Here is a picture below to visualize.

Here is a picture:

My terminal in vs code

This makes my productivity worse because I have only so much screen height to work with. The code should wrap at the end of the screens width but it wraps not even half way to the screen. Is there a way to fix this??? Thanks.

How to write unit test for ZeroDivisionError using try except format

$
0
0

[mac os high sierra 10.13.6, visual studio code 1.39.2]

I want to write the unit test that captures ZeroDivisionError exception.

When the code is written in format function_v1, both test_v1 and test_v2 work.

function_v1

def divide(x, y):
    if y == 0:
        raise ZeroDivisionError("Can not divide by zero!")
    return x/y

===

import unittest
import intro.py #the file in which divide function is in

test_v1

class TestCalc(unittest.TestCase):
    def test_divide(self):
        self.assertRaises(ZeroDivisionError, intro.divide, 1, 0)

test_v2

class TestCalc(unittest.TestCase):
    def test_divide(self):
        with self.assertRaises(ZeroDivisionError):
            intro.divide(1,0)

How can I write test_v1 and test_v2 so they work when the function is written like this:

function_v2

def divide(x, y):
    try:
        return x / y
    except ZeroDivisionError:
        print("Can not divide by zero!")

function_v2 & test_v1, and function_v2 & test_v2 should both show the tests passing, and not giving out the error messages and showing the tests failed.

Results of running the program:

For both function_v1 & test_v1, and function_v1 & test_v2:


Ran 1 test in 0.000s

OK

function_v2 & test_v1:

    Can not divide by zero!

FAIL: test_divide (main.TestCalc)

    Traceback (most recent call last):
      File "/Users/az/Desktop/coreySchafer/test_calc.py", line 35, in test_divide
        self.assertRaises(ZeroDivisionError, intro.divide, 1, 0)
    AssertionError: ZeroDivisionError not raised by divide

Ran 1 test in 0.001s

FAILED (failures=1)

function_v2 & test_v2

Can not divide by zero!

FAIL: test_divide (main.TestCalc)

    Traceback (most recent call last):
      File "/Users/az/Desktop/coreySchafer/test_calc.py", line 33, in test_divide
        intro.divide(1,0)
    AssertionError: ZeroDivisionError not raised

Ran 1 test in 0.002s

FAILED (failures=1)

Why is VS Code adding many blank lines at the end of all my files?

$
0
0

I just installed Win 10 1809 on my Dell PC, and it seems to run okay. But the first thing I did was start up VS Code. I wanted to run yarn start for my React project, but I had to type it way down in the terminal window, while the prompt was at the top. It worked though.

And when I open any project file, there seems to be approximately 100 blank lines appended at the end of each. But the line numbers don't go down that far and the cursor stops at the last line number. But the scroll bar acts as if those blank lines are there.

So I'm guessing the same number of blank lines are being added to the terminal too. But in the terminal window, the cursor is positioned at the bottom of the scrollable window.

What's going on? Is there a fix?

EDITED:

I see that I can scroll the file's window up until the cursor and last line is at the top, but no further, regardless of the window size. Maybe this has always be the case, and I never noticed. But now because of my terminal problem, I am suspicious of everything and checking for any abnormalities. So I don't think that extra blank lines are being added to my files. Sorry for the mistake.

But the terminal problem persists. The screen clip below shows the terminal display after I enter "yarn start". The typed input shows up way down from the initial prompt, and the blank area is a long string of "0D0A" characters. Sometimes I can click on "kill Terminal" and then start a new one and the new one works correctly. But not always.

TerminalScreenSnip

Still trying to figure this out.

Is it possible to customize deprecated language features in VSCode?

$
0
0

In VSCode, Vue devs will see the align keyword highlighted in red in HTML templates. The align keyword is deprecated in plain HTML, but is a valid attribute in Vue, Angular and other frameworks. Here is an example:

Example: Vue template

Is there any way to instruct VSCode to override this settings?

Note: This question was asked before in GitHub but was closed automatically.

Why is the following variable assignment not working correctly?

$
0
0

I tried to convert users input from string to int by casting each character to int and multiply by its corresponding exponential. Everything works correctly till the point I need to assign the result value to a int variable. It always one less than the correct value when the assigned value is between 100 and 1000. i.e. int k=0; k+=100; But printing k shows 99. But k+=1000 works fine.

The solution I found is to change the order of multiplicand and multiplier, but the cause to this situation is still unknown.

string k_input;
cin >> k_input;
int k = 0;
for (int i = 0; i < k_input.length(); i++)
{
    cout << (k_input[i] - '0') << ""<< pow(10, (k_input.length() - i) - 1) << endl;

    k += (k_input[i] - '0') * pow(10, k_input.length() - i - 1);
}

i.e. By inputting 123, output should be 123, but it shows 122 instead.

And inputting 1221 shows 1221 as expected.

Can I install selenium webdriver into Visual Studio Code?

$
0
0

I would like to start writing some selenium scripts using Visual Studio Code.

Can I install the webdriver(s) and how?

In the demonstration video's that I have seen Visual Studio was used, not VSC.

Please guide me since I am not familiar with the VSC editor.

Custom language associations in VS Code based on the contents of the first line

$
0
0

Using VS Code (v1.39.2) when I open a file whose first line is #!/bin/bash, the editor knows to set the language to Shell Script. Is there a way that I can configure my own language associations such that some arbitrary first line is associated with a built-in language (e.g. /bin/hello-world selects Perl)?


vscode : what extension is good for 3 way merging?

$
0
0

I am currently learning vscode and coming from webstorm , is there an option/extension to merge 3 ways? Where in vscode can I merge conflicts? At the moment I thought I resolved all the changes but when I run 'git status' it says there are still unmerged paths? Where can I see them in vscode or when do I know when I merged everything?

Can't find ProjectName.dll attach process for debugging of dotnet core api in vs code?

$
0
0

I am trying to debug dotnet core api in VS Code. But I can't find dotnet process to start debugging. Here is sceen shots.

First one is mine and Second one is i want. Here is mine which I am gettingMine VS Code Screen shot

And here is what I am looking for

enter image description here

You can see in my case I am getting dotnet.exe. But in below pic .dll. How can get this one. Please help because breakpoit did not hit in my case.

How can I set VScode as core editor in git /macbook

$
0
0

I cannot set Visual Studio Code as my core editor for git. When I'm trying to do the git commit I only see the info that there is a problem with editor.

MacBook-Air-Agata:~ agataskrzypczyk$ git config --global core.editor "/Applications/Visual Studio Code.app" --wait

MacBook-Air-Agata:~ agataskrzypczyk$ git config --global core.editor
/Applications/Visual Studio Code.app

MacBook-Air-Agata:~ agataskrzypczyk$ cd nowy

MacBook-Air-Agata:nowy agataskrzypczyk$ git commit

hint: Waiting for your editor to close the file... /Applications/Visual Studio Code.app: /Applications/Visual: No such file or directory
error: There was a problem with the editor '/Applications/Visual Studio Code.app'.
Please supply the message using either -m or -F option.
MacBook-Air-Agata:nowy agataskrzypczyk$

how to show folders files referenced in gitignore in vs code folder tree

$
0
0

Is there a way to whitelist certain folders that are referenced in .gitignore, say, /foo, so that they're shown in the folder tree of vs code? I can't seem to find anything.

Debugging plain JavaScript code without web project

$
0
0

I have a JavaScript file that I'd like to edit and debug.

The code isn't DOM/browser/web specific.

Can I use VS Code to run and debug JavaScript without a web project like Node or ASP.NET? If so, how? Perhaps VS Code assumes it'll have a web server like Node to attach and debug

How should I modify my launch.json if necessary?

Loading a .js file and hitting F5 results in

Connection Failed

OpenDebug process has terminated unexpectedly

enter image description here

enter image description here

Viewing all 98406 articles
Browse latest View live


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