MonoDevelop 3.0 is great, but it's a little too over zealous on reformatting.
When I enter the code:
var serializer = new XmlSerializer (typeof(TDestination),extraTypes);
Then press CTRL+SHIFT+F to format the code, it change these lines to put one parameter on each line making it hard to read when the function calls or lambda expressions are long.
var serializer = new XmlSerializer (
typeof(TDestination),
extraTypes
);
How do I get MonoDevelop to leave the line breaks as they are?
Go to Preferences >> Source Code >> Code Formatting >> C# Source Code. Select a custom policy, press the "C# Format" tab, and press the "Edit" button. I hope that helps!
Related
I'm adding keyboard shortcuts to a Flutter web application.
I have a form within a custom FocusableActionDetector where the shortcut has form like this:
SingleActivator(LogicalKeyboardKey.digit2)
and action is like:
CustomActivateIntent: CallbackAction<CustomActivateIntent>(
onInvoke: (intent) { provider.value = "2"; },)
In the same form I have a couple of numeric TextFormFields. To permit writing the character "2" I have to put these text fields inside some new FocusableActionDetector, otherwise the previous detector catches the command and the text field loses the "2" character, and this is already quite weird... Moreover, after writing in any of the text fields the form focus detector doesn't work anymore.
I think this could be related to the focus system, which is yet not that clear to me.
Can anyone help find a clean solution?
I found a workaround: the FocusableActionDetector is now preceded by an if statement. The code looks like the following:
// I extract the form to a widget to make it clearer
var searchWidget = SearchWidget();
child: textEditingInProgress
? searchWidget
: FocusableActionDetector(
child: searchWidget,
...,
),
The textEditingInProgress bool is a field in a provider and is controlled by the FocusNodes belonging to the TextControllers.
Still this is not a perfect solution, in particular I'd like to understand why the previous approach was not working.
I find that in vs code I can start to type console.log I can leverage intellisense to auto complete the console.log and the cursor is inside the parentheses. However, after typing what to log I still have to either continue to type the closing parentheses or use the right arrow to put me at the end of the command. Is there a plugin so that I don't have to do that? Thanks.
console.log('hello');
^ after this I have to right arrow to the end of semicolon
Not sure which language but Typescript automatically comes with a snippet completion that does this. Just type 'log' and choose the snippet completion that pops up. After typing your log message you can hit Tab to go to the next line.
If your language doesn't have this or you want to customize the snippet you can create your own snippet completions.
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets
If you look at the Typescript/Javascript snippet json it even has the code example for the console.log snippet completion.
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
When creating your own snippets I like putting short categories in the prefix itself.
So if you created your own snippet based on the above, the prefix would be:
"sn fn clog" (Note the spaces)
So you would prepend all your user defined snippet prefixes with 'sn '. That way if you type 'sn ' , you'll see all your custom completion pop up in the completion window. If you type 'fn ' , you'll seen all function custom snippets. Typing 'clog' will just pop up the correct custom logging snippet for you.
How can the bottom pane of a Visual Studio Web Test response show JSON instead of hex values?
I have not found any way of getting just the json in the bottom panel. Some responses include the "View in html browser" link so clicking that will normally show just the json.
The workaround I normally use is to copy the entire response body from the bottom panel, paste it into a text editor (you could have a text file open in Visual Studio as a work area, but I use Notepad++ for this job) and then remove the hex part of the copied text. Both Visual Studio and Notepad++ support column (or box or rectangular) mode allowing the entire hex part to be selected and deleted. The final action is to join the lines to for one long line. This job is so useful, but so tedious with an editor, that I wrote a little C# program to do it.
There is a way to do it. Create an extraction rule that selects a token. This rule will always return positive so the token does not need to exist. When used, it will format JSON in the response window in JSON only:
namespace WebTestPlugins
{
[DisplayName("Output in JSON")]
[Description("Outputs Viewer in JSON")]
public class OutputInJSON : ExtractionRule
{
public override void Extract(object sender, ExtractionEventArgs e)
{
var response= e.Response.BodyString;
var parseresponse = JObject.Parse(response);
e.WebTest.Context.Add("xxxz", parseresponse.SelectToken("xxxx"));
e.Success = true;
return;
}
}
}
I am using InteliJ and really love using it. One of the questions I have is this:
Is there a way to create code short cuts?
For instance, while bug testing, I am forever writing:
<?php die(var_dump($var)); ?>
and figured it would be great to have a shortcut key to automate this. i.e.
"Cmd Option D"
or something similar to dump the pre-defined statement into my code...
Any thoughts on this?
You can use Live Templates:
To define a template go to Settings/Live templates, then select group or create new group of templates and hit the green plus button and select Live Template.
In the abbreviation field type for example vd which will be the trigger for your snippet, define context, which represents the languages this template will be available for and put this in the Template Text field:
<?php die(var_dump($SELECTION$)); ?>
The $SELECTION$ part is a variable which represents current selection.
Now when you are in editor, you can just type vd and hit Tab. That will expand your snippet and put your cursor inside var_dump().
You can event type the variable name you want to dump, select it, hit CTRL+ALT+T, which will show you a Surround with dialog, where you can choose your template. After you select it your variable name will be surrounded with the var_dump snippet.
Another way to invoke a live template is to hit CTRL+J which will show you autocomplete popup with the available templates.
All is in the title.
If a have opened the three files:
/some/relatively/long/path/dir1/file_a
/some/relatively/long/path/dir1/file_b
/some/relatively/long/path/dir2/file_a
The file dropdown contains:
file_a (/some/relatively/long/path/dir1)
file_a (/some/relatively/long/path/dir2)
file_b (/some/relatively/long/path/dir1)
And that bother me because I have to look on the right to differentiate the two file_a, and on the left for the others. This happens a lot to me mostly because I code in python, and thus I often have several __init__.py files opened.
How do I get jedit to display
/some/relatively/long/path/dir1/file_a
/some/relatively/long/path/dir1/file_b
/some/relatively/long/path/dir2/file_a
config:
jedit 5.1.0
java 1.6.0_26
mac osx 10.6
Unfortunately this is not easily possible currently, I just had a look at the source and this is not configurable.
You can:
Submit a Feature Request to make this configurable (good idea in any case)
Create or let create a startup macro that
registers an EBComponent with the EditBus that listens for new EditPanes getting created
retrieve the BufferSwitcher from the EditPane
retrieve the ListCellRenderer from the BufferSwitcher
set a new ListCellRenderer to the BufferSwitcher that first calls the retrieved ListCellRenderer and then additionally sets the text to value.getPath()
Try the Buffer List plugin as to whether it maybe suits your needs
Now follows code that implements the work-part of option two, runnable as BeanShell code which does this manipulation for the current edit pane. The third line is not necessary when done in an EBComponent, this is just that the on-the-fly manipulation is shown immediately.
r = editPane.getBufferSwitcher().getRenderer();
editPane.getBufferSwitcher().setRenderer(
new ListCellRenderer() {
public Component getListCellRendererComponent(list, value, index, isSelected, cellHasFocus) {
rc = r.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
rc.setText(value.getPath());
return rc;
}
});
editPane.repaint();