visual-studio-code

VSCode Extenstion how to get Position of last character of line

删除回忆录丶 提交于 2021-01-28 02:19:22
问题 I am developing a VSCode plugin, and now want to get the position of the last character of a line. Now I want to get it through a known Position object, using "with" method. The official reference is here: https://code.visualstudio.com/api/references/vscode-api#Position You see "with" method has 2 overloads. Now I want to use the "with(change: {line: number, character:number})" method: const endPos = startPos.with({ line: 1, character: -1 }); startPos is a "Position" object. But this code is

How to hide file paths when running Python scripts in VS Code?

混江龙づ霸主 提交于 2021-01-28 00:34:26
问题 Every time I run my code, the terminal at the bottom is displaying this long name (I think the file location) as well as whatever output it's supposed to display. Is there a way to get that to go away? This is what it looks like: administrator@Machintosh-2 Exercise Files Python % /user/bin/python3... Hello world! administrator@Machintosh-2 Exercise Files Python % 回答1: AFAIK, there is no way to hide the paths, because the VS Code Integrated Terminal is basically using your OS/system's

How to access Nuget repository from .NET Core using Visual Studio Code

我的未来我决定 提交于 2021-01-27 22:59:48
问题 I'm working on a .NET Core project with a friend and we're splitting the work as we see best. We're currently trying to configure a database application to communicate with so we need a database "driver" library. I've decided on MongoDB, and I've found this page which seems to suggest that the following code will configure our project somehow to use the library. Selecting .NET Core and Nuget (both of which I've installed locally and on our server), I get the following code which seems to be

Multiple formatters in Visual Studio Code

末鹿安然 提交于 2021-01-27 22:15:08
问题 In my team, some people are using VS Code and others WebStorm. To align code format, I've written an extension for VS Code that adds some missing rules. My plan was to run my extension along with the native formatters that ship with VS Code. I provide my edits using the API: vscode.languages.registerDocumentFormattingEditProvider('typescript', { provideDocumentFormattingEdits(document: vscode.TextDocument) { const textEdit: vscode.TextEdit[]; return textEdit; } } But it seems I can't run this

How to configure VS Code to be able to step into a shared library (.so) that is loaded when debugging a Python script?

佐手、 提交于 2021-01-27 20:23:17
问题 Using gdb from the command line I'm able to break when the shared library is loaded. How can I get the same behavior in VS Code knowing that I have the source code of the shared library? 回答1: For me it works somehow. Here's my setup: Ubuntu 18.04, debugging a C++ shared library I load from Python3 (more specifically - via Cython, but IIRC it worked equally well when loading a .so through ctypes, also I remember it working when debugging a pure C lib in a similar setup) in VSCode I have a

Hide/fold/dim arbitrary lines of code by regex (e.g. to hide logging)

半世苍凉 提交于 2021-01-27 19:59:03
问题 There is a lot of logging in my C++ project. The logging is done via a log stream and the log lines have the following format: APP_LOG_XXX() << ... ; Those log lines blend with the rest of the code and make it harder to be read. I want to somehow make these log lines appear in dimmed colors, or even better to hide/fold by a hotkey or click. There are a lot of log lines already, so wrapping them up in #pragma region would take much time (or would require writing a separate script). I wonder if

Visual Studio Code clang error: linker command failed with exit code 1 on Mac

限于喜欢 提交于 2021-01-27 19:10:00
问题 I'm new to programming and wanted to try out VS Code for C++ development. I'm getting this error and I can't find a solution online how to fix: clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process terminated with exit code: 1 I got a cpp file with the function definitions and a header file with the class and declarations in it and also a int main test file. So its a linker issue. VSC directed me to c_cpp_properties.json and I have no idea what

VSCode Regex Find/Replace In Files: can't get a numbered capturing group followed by numbers to work out

♀尐吖头ヾ 提交于 2021-01-27 18:57:44
问题 I have a need to replace this: fixed variable 123 with this: fixed variable 234 In VSCode this matches fine: fixed(.*)123 I can't find any way to make it put the capture in the output if a number follows: fixed$1234 fixed${1}234 But the find replace window just looks like this: I read that VSCode uses rust flavoured rexes.. Here indicates ${1}234 should work, but VSCode just puts it in the output.. Tried named capture in a style according to here fixed(?P<n>.*)123 //"invalid regular

Breakpoint on continue in if statement not hit

不打扰是莪最后的温柔 提交于 2021-01-27 18:42:54
问题 In the following code, both a and b are outputs of generator functions, and could evaluate to None or have a value. def testBehaviour(self): a = None b = 5 while True: if not a or not b: continue print('blaat') If I put breakpoints (using Visual Studio Code) on the line with the continue statement, and the line with the print statement, neither is hit. The print statement is not called, and the loop just keeps running indefinitely as expected, but I would expect that breakpoints are hit. If I

How to enable race detector for Golang in Visual Studio Code?

女生的网名这么多〃 提交于 2021-01-27 18:08:58
问题 I searched in many web pages to find what phrase exact should I place in settings.json in VS Code Golang extension (released by Microsoft) to add a build flag (in my case, race detector)? I added: "go.buildFlags": ["-race"], in extension's settings.json but still when debugging, in a function that definitely generates a race condition, the debugging console does not denote something like: Found 1 data race(s) which the go compiler usually indicates when executing the same file via go run