Load settings view from code - visual-studio-code

I'm working on an extension and I'm checking to see if settings have values, if not, I want to show an error and provide a button that launches the settings editor so the user can add those settings.
I think my path forward is to use executeCommand and provide a built in command that does this for me, but I've been having trouble finding a list of built-in available commands.

Hidden in the key-bindings section of the documentation, I found the command I was looking for - workbench.action.openGlobalSettings
The full solution looks like
commands.executeCommand('workbench.action.openGlobalSettings');

Related

Opening the VSC settings window from code

I'm working on a Visual Studio Code extension, where some settings are required for it to work properly. Right now, in case the user has forgotten something, I'm showing a warning message indicating this, and telling them to fix this property in the settings. I would, however, like to add a button that opens the settings page of that property.
However, after looking around for over an hour, I can't seem to find any support for this in the Api, or anyone else asking this question (which I find a bit weird?). If it really doesn't exist, I'd still expect at least 1 other person asking this somewhere, but as far as I can see there's absolutely nothing.
Is it possible to open the settings window (preferably even filtering them down to only my extension's properties/the one property that has to be filled in) from code?
Thanks in advance
I found it out myself after digging through the keybinds window. You can use the following to open the settings:
vscode.commands.executeCommand("workbench.action.openSettings2");
I did not, however, find how to pass a search query into it to open a specific place in the settings.
EDIT: You can use openSettings & add the search query as an extra argument to executeCommand. For example - if your property is defined as my.extension.property in package.json, you can use this:
vscode.commands.executeCommand("workbench.action.openSettings", "my.extension.property");

How to access per project / per preset configuration data in vue-cli 3.x?

I'm looking to create a vue-cli 3.x plugin that generates extra files in the project when invoked and templates these based on configuration info entered by the user.
It's rather easy to collect this information from user prompts but it'd be much nicer if users could put this info into some sort of configuration file and have the plugin read it from there.
I understand vue-cli now uses a vue.config.js file on the project level and ~/.vuerc on a more global (preset) level. However, it doesn't look like my generator function would have access to either one of those files.
"The entire preset" should be passed as the third argument to the function when invoking the plugin with module.exports = (api, options, rootOptions) => {} in ./generator/index.js, rootOptions is undefined.
Sililarly, the use of vue.config.js is discussed in the documentation when talking about service plugins, but there's no mention how to use it in a generator function.
Am I missing something obvious here or is there really no officially sanctioned way to do this? Nothing stops me from reading vue.config.js in my function, but this feels hacky. And I wouldn't even know how to find out which preset was used to create the project.
So your problem is that you can't find ~/.vuerc?
I had the same issue and I found the solution here.
The solution is to use the command line
vue config
to see .vuerc, and then use
vue config --delete presets.yourPresetName
to delete your preset.
As well, if you can't type in your preset name in the terminal because it contains a space or an apostrophe, you can use
vue config --edit
to open .vuerc with a text editor and just edit it there

Where the heck is Unity's CrossPlatformValidator?

I'm trying to use Unity's excellent new CrossPlatformValidator
(Such as seen ...
http://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html or
https://docs.google.com/document/d/1dJzeoGPeUIUetvFCulsvRz1TwRNOcJzwTDVf23gk8Rg)
But it can't be found! Naturally I am ...
using UnityEngine;
using UnityEngine.Purchasing;
I also tried different stripping and .Net levels. Nothing.
Anyone have a clue about this?
The type or namespace name `CrossPlatformValidator' could not be found. Are you missing a using directive or an assembly reference?
Stuff like this is usually found at UnityEngine.Experimental but it wasn't there when I looked so I guess it is not a new feature.
1. You can find it by going to Windows -> Services. Sign in on the Window displayed, usually on the right.
2. Create a Project ID on that Window.
3. Click on In-APP Purchasing. It is checked to OFF, click on it then click Enable.
Note: You must Sign in to be able to Enable it and you must Enable it before you can use it from Script.
Finally, the completely undocumented namespace is:
using UnityEngine.Purchasing.Security;
note that one can see this in the generated "tangle" files, for example, if one forgets it. :/
Mono Dev can often help you find things.
Right click on unresolved class -> Resolve
Screenshot of resolve function in Mono Dev.:

Dynamically loaded javascript doesn't show in sources panel?

For example, I have an ajax request and it returns <script src='buggy.js'></script>.
Problem is, it doesn't show up in sources or resources panel. That means I can't do all the cool stuffs like adding breakpoint and inspecting the elements as they run.
I could only see the source of the js file under the Network panel.
Is there anyway to make chrome add them to the sources panel?
Or how do you guys go about debugging dynamically added scripts?
Using Canary.
I was having the same problem, and I found a workaround that is better than the deliberate exception. It does still require changing the code as opposed to just setting a breakpoint inside the chrome dev tools.
I tried using the "//# sourceURL=dynamicScript.js" that was suggested as a workaround by the OP, but it still wasn't showing up for me unless it already existed in my tabs from a previous time when it produced an exception.
Coding a "debugger;" line forced it to break at that location. Then once it was in my tabs in the Sources panel, I could set breakpoints like normal and remove the "debugger;" line.
Please refer to https://developer.chrome.com/devtools/docs/javascript-debugging#breakpoints-dynamic-javascript
(Original link is broken-- archived link below)
http://web.archive.org/web/20141016164821/https://developer.chrome.com/devtools/docs/javascript-debugging#breakpoints-dynamic-javascript ("Breakpoints in Dynamic JavaScript").

adding python interpreters programmatically

Is there a simple way to add and change interpreters using the Pydev plugin interface? I'm running pydev 1.6.1 and I'd like to be able to add and use a given interpreter based on a list of available interpreters in my environment.
Right now I can see the PythonInterpreterManager has a createInterpreterInfo call, but that doesn't seem to do anything. Looking at the source for pydev, it seems like I have to actually work with the preference pages to keep track of all of them.
Is there a simpler set of functions I can call to add these?
PythonInterpreterManager manager = (PythonInterpreterManager)PydevPlugin.getPythonInterpreterManager(true);
IInterpreterInfo info = manager.createInterpreterInfo(execPath, new NullProgressMonitor());
manager.addInterpreterInfo(info);
I can already do the above, but that only caches it, but doesn't display it as a valid interpreter option in the preferences.
I've even tried doing reflection to add these without much luck. I can call addNewInput on the editor as the Add button does, but then it says it doesn't have any knowledge of that interpreter. I've tried creating a popup preferences page and adding the values to the various members via reflection as getNewInput() would, but still don't see any more options in the preference page. I'm not sure if this is because I'm missing something or the popup preference page I make is totally unrelated to the page that pops up using the Window->"Preferences" pulldown.
The API is something as:
IInterpreterManager iMan = PydevPlugin.getPythonInterpreterManager(true);
IInterpreterInfo interpreterInfo = iMan.createInterpreterInfo("c:/python/python.exe", monitor, false);
iMan.setInfos(new IInterpreterInfo[]{interpreterInfo}, null, null);
Note that if you have 'manager.addInterpreterInfo' in there, you probably have an old version of PyDev... (and at that call you set all the interpreters available, so, if you want to keep some configuration, you should query it and add them back).
You can use: org.python.pydev.editor.codecompletion.revisited.javaintegration.AbstractWorkbenchTestCase.createPythonInterpreterManager(NullProgressMonitor) as a reference.