What are Visual Studio Code experiments? - visual-studio-code

Today I was surprised to find an "Enable Experiments" option under VSCode's Workbench settings, turned on by default.
The setting's description is "Fetches experiments to run from a Microsoft online service" which seems rather vague to me. I tried googling this but didn't find any clear answers.
So, does anybody know what those "experiments" are and if it would probably be better to turn this off?

This is one of the case where using open-source software is a good idea. Because the source code of visual studio code is published in https://github.com/Microsoft/vscode. We could try to search in where the code would be used.
First, we could try to search the string Enable Experiments. And see, to which action the option is tied to. From there, I see that, the file src/vs/workbench/contrib/experiments/node/experimentService.ts is using it. Specifically, when trying to load an experiment in line 173
if (!product.experimentsUrl || this.configurationService.getValue('workbench.enableExperiments') === false) {
We see that, the code would check for "experiment URL". this could be seen in product.json which #Joey mentioned in the comment. In my case, the text looks like this.
"experimentsUrl": "https://az764295.vo.msecnd.net/experiments/vscode-experiments.json",
From there, we could see the content of the JSON file by making a GET request to that URL. And, it returns this (at least, at the time I make the request)
{
"experiments": [
{
"id": "cdias.searchForAzure",
"enabled": true,
"action": {
"type": "ExtensionSearchResults",
"properties": {
"searchText": "azure",
"preferredResults": [
"ms-vscode.vscode-node-azure-pack",
"ms-azuretools.vscode-azureappservice",
"ms-azuretools.vscode-azurestorage",
"ms-azuretools.vscode-cosmosdb"
]
}
}
}
]
}
Based on the response, I could see that, it try to alter my search result if I search using "azure" key word. Which I tried, and the search result shows the 4 items there on top of the result search.
As to whether to disable it or not. On safe side (if you don't want for it to alter your experience using vscode) I think you would want to disable it. But, I don't think microsoft would do something crazy.

I just noticed this one and was curious about it as well. A search through the VS Code release notes finds one reference to it in July 2018. workbench.enableExperiments is listed as one of the settings for VS Code's "Offline mode": https://code.visualstudio.com/updates/v1_26#_offline-mode
The description of offline mode suggests that this settings is for "A/B experiments":
To support this offline mode, we have added new settings to turn off features such as automatic extension update checking, querying settings for A/B experiments, and fetching of online data for auto-completions.
As mentioned by others, the source code for VS Code shows this setting being used in experimentService.ts: https://github.com/microsoft/vscode/blob/93bb67d7efb669b4d1a7e40cd299bfefe5e85574/src/vs/workbench/contrib/experiments/common/experimentService.ts
If you look at the code of experimentService.ts, the stuff it's fetching seems to be related to extension recommendations, notifications about new features, and similar things. So it looks like the experiment service is for fetching data to do A/B testing of feature and extension recommendations to users.

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");

VS Code Extension to Update Workspace Settings

I have been combing through VS Code API docs, and am trying to understand whether or not it is actually feasible to write an extension that can edit the global User Settings JSON file.
Am I correct in thinking that I can create my extension, add the metadata I'm after under the "contributes" section in the "configuration" child object, then based on those values when the plugin is activated, take action against the User's preferences JSON?
I've also looked at the Guides plugin's configuration to check other examples, I'm just having a hard time conceptualizing how all this works, so any pointers would be appreciated.
I'm definitely NOT asking for someone to write my extension, just provide an answer as to whether I'm understanding the mechanics of an extension as a developer.
Would this work?
import { ConfigurationTarget, workspace } from 'vscode';
const configuration = workspace.getConfiguration(<YOUR_SECTION>);
configuration.update(<SETTING_NAME>, <SETTING_VALUE>, ConfigurationTarget.Global).then(() => {
// take action here
});
More information about the WorkspaceConfiguration object located here.

TinyMCE: Copy-Paste from Google Docs

Folks,
My company needs to support the following workflow:
- There's rich content getting created in Google Docs (with simple formatting - bold/italic, as well as hyperlinks)
- That content is then pasted into an internal CMS that uses TinyMCE.
Problem: all formatting gets lost when pasting stuff in.
Already tried the "paste from Word" plugin - it doesn't work.
Please advise. Thank you!
UPDATE:
I narrowed the problem down to Google Chrome. Firefox works just fine. I also used the paste_pre_processing() callbacks - the data gets corrupted before getting in there.
I ended up giving up on the Paste plugin into TinyMCE. Instead, I used the undocumented valid_styles property of TinyMCE. This solved the problem fine for my scenario. Here's the config snippet we ended up using:
valid_elements: "a[href|title|target],del,b,strong,del,i,blockquote,p,br,em,ul,li,ol,span[style]",
valid_styles : { '*' : 'font-weight,font-style,text-decoration' },
I know this question was asked a long time ago however I am making an application that requires a copy and paste from google drive into tiny mce. This is actually fairly simple with the free paste plugin. Simply remove the filters so that it can copy in all of the data.
tinymce.init({
selector: 'textarea',
plugins: "paste",
paste_data_images: true,
paste_enable_default_filters: false,
paste_remove_styles_if_webkit: false
});
Your problem is a somewhat complex issue.
First you need to make sure that tinymce does not remove tags and tag-attributes that it recognises as invalid (have a closer look at the tinymce configuration options valid_elements and valid_children).
Second you will have to implement an own handling of the paste process.
There are three way to do this. The most time consuming option is to write an own custom paste plugin and replace the given one. The other options are ways to configure the paste plugins and define own functions to interact with and change the pasted content.
The seetings paste_pre_processing and paste_post_processing are the way to go here.

Is there a way to change bracket placement and indentation in Xcode?

I want to change the default behavior of XCode (4) for aligning brackets from this:
- (BOOL)someValue {
return _someValue;
}
To this:
- (BOOL)someValue
{
return _someValue;
}
I've reviewed the docs here:
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Reference/XcodeUserDefaultRef/100-Xcode_User_Defaults/UserDefaultRef.html#//apple_ref/doc/uid/TP40005535-CH3-SW57
But I still dont' understand how to make the change. Any help?
First off, the documentation you referred to is for XCode 3.1 (I've linked the introduction page which says so clearly). Judging by the number of comments on devforums.apple.com about this, I think the XCCodeSenseFormattingOptions key no longer exists under the new XCode4 defaults (which are stored under bundle ID com.apple.dt.XCode). If you want this particular feature restored, file a bug with Apple.
Secondly, you might be able to do what you're looking for by modifying templates. I discovered this very related question, but there's no tacit confirmation there that the suggestion actually succeeded.
You could try using an application called Snippet Edit that allows you to easily edit all of the supplied code snippets. You will need to be using Xcode v4.3 or later though if you wish to use it.
The application can be found at http://cocoaholic.com/snippet_edit/

how can I improve iPhone UI Automation?

I was googling a lot in order to find a solution for my problems with UI Automation. I found a post that nice summarizes the issues:
There's no way to run tests from the command line.(...)
There's no way to set up or reset state. (...)
Part of the previous problem is that UI Automation has no concept of discrete tests. (...)
There's no way to programmatically retrieve the results of the test run. (...)
source: https://content.pivotal.io/blog/iphone-ui-automation-tests-a-decent-start
Problem no. 3 can be solved with jasmine (https://github.com/pivotal/jasmine-iphone)
How about other problems? Have there been any improvements introduced since that post (July 20, 2010)?
And one more problem: is it true that the only existing method for selecting a particular UI element is adding an accessibility label in the application source code?
While UI Automation has improved since that post was made, the improvements that I've seen have all been related to reliability rather than new functionality.
He brings up good points about some of the issues with using UI Automation for more serious testing. If you read the comments later on, there's a significant amount of discussion about ways to address these issues.
The topic of running tests from the command line is discussed in this question, where a potential solution is hinted at in the Apple Developer Forums. I've not tried this myself.
You can export the results of a test after it is run, which you could parse offline.
Finally, in regards to your last question, you can address UI elements without assigning them an accessibility label. Many common UIKit controls are accessible by default, so you can already target them by name. Otherwise, you can pick out views from their location in the display hierarchy, like in the following example:
var tableView = mainWindow.tableViews()[0];
As always, if there's something missing from the UI Automation tool that is important to you, file an enhancement request so that it might find its way into the next version of the SDK.
Have you tried IMAT? https://code.intuit.com/sf/sfmain/do/viewProject/projects.ginsu . It uses the native javascript sdk that Apple provides and can be triggered via command line or Instruments.
In response to each of your questions:
There's no way to run tests from the command line.(...)
Apple now provides this. With IMAT, you can kick off tests via command line or via Instruments. Before Apple provided the command line interface, we were using AppleScript to bring up Instruments and then kick off the tests - nasty.
There's no way to set up or reset state. (...)
Check out this state diagram: https://code.intuit.com/sf/wiki/do/viewPage/projects.ginsu/wiki/RecoveringFromTestFailures
Part of the previous problem is that UI Automation has no concept of discrete tests. (...)
Agreed. Both IMAT and tuneup.js (https://github.com/alexvollmer/tuneup_js#readme) allow for this.
There's no way to programmatically retrieve the results of the test run. (...)
Reading the trailing plist file is not trivial. IMAT provides a jUnit like report after a test run by reading the plist file and this is picked up by my CI Tool (Teamcity, Jenkins, CruiseControl)
Check out http://lemonjar.com/blog/?p=69
It talks about how to run UIA from the command line
Try to check the element hierarchy, the table can be placed over a UIScrollView.
var tableV = mainWindowTarget.scrollViews()[0].tableViews()[0].scrollToElementWithName("Name of element inside the cell");
the above script will work even the element is in 12th cell(but the name should be exactly the same as mentioned inside the cell)