VSCode keybinding to navigate to render method - reactjs

so I am using VSCode for react development and I was wondering if I could jump to the render function with a shortcut. Naturally there is no preconfigured way. So I looked into it and found a GitHub issue.
{
"key": "shift+alt+p",
"command": "workbench.action.quickOpen",
"args": "#:render"
},
Problem is, that the shortcut opens up the vscode window. Which is prefilled and I have to press the enter button to do the actual "navigate to". Does anyone know how to do this without pushing enter?

I think the only way is to use a macro to run both the quickOpen command and selecting with one keystroke.
Using a macro extension like multi-command, put this into your settings:
"multiCommand.commands": [
{
"command": "multiCommand.goToRender",
"sequence": [
{
"command": "workbench.action.quickOpen",
"args": "#:render"
},
"workbench.action.acceptSelectedQuickOpenItem"
]
}
]
and some keybinding to trigger that macro (in your keybindings.json):
{
"key": "shift+alt+p",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.goToRender" },
"when": "editorTextFocus"
}
Of course, if you have multiple render objects the first will be selected and navigated to.
An alternative is to use the selectBy extension which you could configure to jump to the next or previous occurrence of the word render. The extension can move to occurrences of words (and not select anything). In your settings:
"selectby.regexes": {
"goToRender": {
"moveby": "render",
}
}
And some keybindings (whatever bindings you want):
{
"key": "shift+alt+p", // go up to the previous `render`
"when": "editorTextFocus",
"command": "moveby.regex",
"args": ["goToRender", "moveby", "prev", "start"]
},
{
"key": "alt+p", // go to the next `render`
"when": "editorTextFocus",
"command": "moveby.regex",
"args": ["goToRender", "moveby", "next", "start"]
},

Related

Setting up VS Code for C using Cygwin64 Compiler and Debugger on Windows (ERROR: Unable to start debugging)

I am trying to set up VSCODE to debug a C program on Windows using Cygwin64.
I used the config suggested by #stephw ( Setting up VS Code for C using Cygwin64 Compiler and Debugger on Windows ), but it did not work for me.
I cannot comment on the original post, because I do not have enough reputation points, and I cannot answer because I do not know the answer to the original question.
The name of the script is dirigir.c and I can compile. The file dirigir.exe is created. But...
I get the following error:
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Error creating process /usr/bin/E:\cloud\Backup\Trabalhos com programas\C and Cpp\scripts/e:\cloud\Backup\Trabalhos com programas\C and Cpp\scripts\dirigir.exe, (error 2).
For some reason, /usr/bin/... / is inserted in the path and the path to the .exe is duplicated.
My launch.json file is as recommended:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PATH",
"value": "%PATH%;z:\\cygwin64\\bin"
}
],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"logging": { "engineLogging": true }, //optional
"preLaunchTask": "gcc.exe build active file"
}
]
}
And my tasks.json is as follows:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:\\cygwin64\\bin\\gcc.exe",
"args": [
"-g",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-Werror", // Optional
"-Wall", // Optional
"-Wextra", // Optional
"-ansi", // Optional
"-pedantic", // Optional
"${file}"
],
"options": {
"cwd": "C:\\cygwin64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
]
}
Do you have any idea how to proceed? Thank you in advance.
Finally, I got it working.
Based on WardenGnaw's answers in this thread:
[cppdbg] Cygwin 10.1-1: intergatedTerminal unable to take input #6475 and, of course, #stephw's answer in the original question this one is based, I can debug my C program.
First, I saved a VSCODE workspace in the same folder where my c programs are.
Then, I used the latest Cygwin gdb version (10.2-1). Did not work (I received the error message that made ask this question). Then, I tried 9.2-1 and now it is working.
It is important to remember to add "C:\cygwin64\bin" to PATH.
I changed my launch.json just a little bit. Notice the "preLaunchTask" key does not have the exact same value that the "label" key in the tasks.json has:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PATH",
"value": "%PATH%;C:\\cygwin64\\bin"
}
],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"logging": { "engineLogging": true }, //optional
"preLaunchTask": "gcc.exe build active file"
}
]
}
My tasks.json is this (notice my name in the end, in the "detail" key):
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\cygwin64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Leonardo."
}
]
}
I notice something a little bit strange:
When I press F5, it does not work, because the task created is not found.
When I edited my launch.json file (preLaunchTask key) to the exact same value in the tasks.json file, the "not found" error disappears, but the debugging process does not start.
"preLaunchTask": "C/C++: gcc.exe build active file"
If I press the Run and debug play button, the debug process does not work either.
When I use the Command Palette (pressing CTRL+SHIFT+P), and click C/C++: Build and Debug Active File,
and then choose the task I created (the second one appears to be automatic),
the program is compiled and the debug process is started.
This is my very simple test script:
#include <stdio.h>
#include <stdlib.h>
int main() {
/* declare and initialize string */
char myString[] = "This is an example of string declaration!";
/* print string */
printf("%s", myString);
int numberA = 5;
int numberB = 10;
int sum = numberA + numberB;
/* Printing a number */
printf("A soma de numberA + numberB é: %d", sum);
return 0;
}
I hope this question and answer can help someone in the future. Peace.
None of the .json changes described here worked for me with gdb 10.2-1. The only thing that did work was the downgrade to gdb 9.2-1, which solved the problem instantly.

Launch.json - Wait for first debugger to load, then execute second

I'm pretty new to debugging like this (I'm coming from a .NET background in VS where you pretty much have nothing to worry about).
I'm having an Electron / React setup that I had a pretty hard time to setup in the first place but it works pretty fine now. (From what I read, I'm not alone)
I was fine using the "devTool" for chrome for a while until I required breakpoint and line by line debugging for more complex stuff where it becomes a pain.
I have this so far:
{
"version": "0.2.0",
"configurations": [
{
"name": "Electron: Main",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
"runtimeExecutable": "npm.cmd",
"runtimeArgs": [
"run-script", "start"
],
"port": 5858
},
{
"name": "Electron: Renderer",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceRoot}",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
}
  }
],
"compounds": [
{
"name": "Debug",
"configurations": ["Electron: Main", "Electron: Renderer"]
}
]
}
The two debugger configuration works perfect. If I trigger "Main", then wait for it to open and then trigger the "Renderer" to attach to chrome, it works just fine.
The issue is that I am human. I can't trigger the second one fast enough so If I have stuff I want to debug onload, then I can't.
The "Coumpound" I made is not trigger on time and trigger way too early (I guess when the debugger is attached). It gives me an error message saying it can't attach to said port (which is normal as it hasn't loaded yet.
Question is. How do I make it "wait" for the main to be ready. Is that even doable?
thanks,
Have you had a look at the documentation? Outside of VSCode, it appears you can run the electron command with an --inspect=[port] or --inspect-brk=[port] flag. Then, launch Chrome and visit chrome://inspect and select the launched Electron app.
It appears your launch.json might need to be updated a little bit, here's what that page (on debugging in VSCode) says it should be. I am noticing you are using workspaceRoot instead of workspaceFolder.
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
},
"args" : ["."],
"outputCapture": "std"
}
]
}

Azure Logic Apps parameters - how to use it?

For a few weeks now, there is a new "Parameter" section in the Designer of Logic Apps. We can create parameters and use these parameters in the Logic Apps:
Unfortunately, there are two things that are missing (or not working yet):
We are not able to set the "current value" of a parameter (as shown below, the field Actual Value is grayed)
When we export the Logic App as an ARM template, parameters are not used in the ARM template as ARM parameters.
Am I missing something or is it just due to the fact that there are features not yet deployed?
I'm not either sure how default/actual values should work in the Logic App designer but for the export of the ARM template with the (designer) parameters I'm using the last build of LogicAppTemplateCreator and it works for me.
The template snippet contains "paramDateFrom" parameter with its default value and it is used in the parameters section of ARM:
...
"paramDateFrom": {
"type": "string",
"defaultValue": "2019-12-19"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2016-06-01",
"name": "[parameters('logicAppName')]",
"location": "[parameters('logicAppLocation')]",
"dependsOn": [],
"properties": {
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"DateFrom": {
"defaultValue": "[parameters('paramDateFrom')]",
"type": "String"
}
},
...
The template parameters file contains the actual value:
...
"parameters": {
"paramDateFrom": {
"value": "2019-12-20"
}

is there any way to move cursor multiple lines at the time in sublime text with keyboard shortcut instead of one line at the time?

I used to move cursor up and down with "UP" and "DOWN" keys.
but it can only move 1 line at the time.
sometimes I would love to move 2 or 3 lines at the time.
i'm wondering if thers's such feature in sublime text editor ?
You can record a macro (CTRL+Q or Tools -> Record/Stop Macro) and save it (just use cursor up/down as often as you like.
Then assign a key or key-combination to the macro file. The key assignement has to look like this. I called the macros "multiple_lines_down" and "multiple_lines_up".
Then assign the macros to your keymap:
{ "keys": ["alt+down"], "command": "run_macro_file", "args": {"file": "Packages/User/multiple_lines_down.sublime-macro"}},
{ "keys": ["alt+up"], "command": "run_macro_file", "args": {"file": "Packages/User/multiple_lines_up.sublime-macro"}},
Macro-File (5 times up) looks like this. Replace false with true to move downwards or just record another macro.
[
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
}
]

Angular schema form destroyStrategy works only on siblings that are array of objects. It does not work on other siblings

I have not been successful in getting the destroy strategy to work on any sibling properties or sibling objects. It only works on sibling array of objects. Please check this example:
$scope.schema = {
"type": "object",
"properties": {
"propertyOne": {
"type": "string",
"enum": ["option1", "option2"],
"title": "Property One Select"
},
"propertyTwo": {
"type": "string",
"enum": ["option3", "option4"],
"title": "Property Two Select"
},
"objectOne": {
"type": "object",
"properties": {
"objectOnePropertyThree": {
"type": "string",
"enum": ["option5","option6"],
"title": "Property Three Select"
}
}
},
"arrayOfObjects": {
"type": "array",
"items": {
"type": "object",
"properties": {
"arrayObjectPropertyFour": {
"type": "string",
"enum": ["option7","option8"],
"title": "Property Four Select"
}
}
}
}
},
"required": ["propertyOne"]
};
$scope.form = [{
"key": "propertyOne"
}, {
"key": "propertyTwo",
"condition": "model.propertyOne === \"option1\""
},{
"key": "objectOne.objectOnePropertyThree",
"condition": "model.propertyOne === \"option1\""
},{
"key": "arrayOfObjects",
"condition": "model.propertyOne === \"option1\""
},
{
"type": "submit",
"title": "Save"
}];
http://jsfiddle.net/mutharasus/dp18a70b/
In here if you select the first dropdown to "Option1" then select all the other dropdowns and save. Then go back and switch the first dropdown to "Option2" and save you can see that only the very last array of objects is removed with the destroy strategy.
Am I doing something wrong or is this a bug in angular-schema-form? I looked under the issues that are currently open in the github project and I do not see an open issue about this.
You're correct, it's not currently behaving the way that you expect when an individual field is removed from the view because of a condition.
Here's what's happening: under the "old" bundled decorators for ASF, each field-type decorator is rendered on the page within an outer tag. The contents of the appropriate field template are then processed and rendered. Condition logic applies to everything within the tag, but not to the tag itself. Normally, this would be fine, but the destroyStrategy logic was assigned to the $destroy event of the tag. The end result is that the $destroy event will never fire unless the entire tag would be removed from the DOM. This is why the model values in the array of objects are being cleaned up - the container is removed when the "model.propertyOne === 'option1'" condition fails, which cascades the $destroy event to each object in the array.
I think that this got overlooked with the creation and release of the new builder, because I raised the issue at the end of the PR for the feature (https://github.com/Textalk/angular-schema-form/pull/371).
On the bright side, the new builder approach (which you can use by adding the bootstrap-decorator file from https://github.com/Textalk/angular-schema-form-bootstrap) doesn't have this issue. Instead, the destroyStrategy logic is applied via directive to the form fields because the tag is no longer used. Unless you have a need to stay with the old decorators at this time, I suggest grabbing the new ones and giving them a try.
Let us know how it goes!

Resources