Update read me

This commit is contained in:
Sandeep Somavarapu
2017-10-20 15:39:40 +02:00
parent bf08a15ba3
commit 282715d434
2 changed files with 130 additions and 43 deletions

View File

@ -15,11 +15,68 @@ This sample shows
Explains how to test this extension in an Empty workspace
### Testing Window configuration
- Open User Settings and set `"conf.view.showOnWindowOpen": "scm"`
- Refresh the Window. SCM view will be shown always, even if you refresh from a view other than SCM.
- Run the command `Configure view to show on window open` and Select the value (View to show when opening a window)
- Value should be updated in `User Settings`
### Testing Resource configuration
- Open User Settings and set `"conf.resource.insertEmptyLastLine": {"${absolute_path_to_file}": true}`
- Open the above configured file in the empty window. A message about adding empty line from the extension is shown.
- Open a different file. No message is shown.
- Run the command `Configure empty last line for current file`
- Value in User settings is updated. Message is shown now
- Run the command `Configure empty last line for files` and provide abosoulte path of another file
- Value should be updated in User Settings
## Folder Workspace
Explains how to test this extension in a Folder workspace
### Testing Window configuration
- Open User or Workspace Settings and set `"conf.view.showOnWindowOpen": "scm"`
- Refresh the Window. SCM view will be shown always, even if you refresh from a view other than SCM.
- Run the command `Configure view to show on window open`. Select the value (View to show when opening a window)
- Pick the target `User Settings` or `Workspace Settings` into which the value should be updated
- Value should be updated in selected target
### Testing Resource configuration
- Open User Settings and set `"conf.resource.insertEmptyLastLine": {"${absolute_path_to_file}": true}`
- Open the above configured file in the empty window. A message about adding empty line from the extension is shown.
- Open a different file from the opened folder. No message is shown.
- Run the command `Configure empty last line for current file`
- Value in Workspace settings is updated. Message is shown now.
- Run the command `Configure empty last line for files` and provide abosoulte path of another file.
- Pick the target `User Settings` or `Workspace Settings` into which the value should be updated
- Value should be updated in selected target
### Multiroot Workspace
Explains how to test this extension in a Multiroot workspace
### Testing Window configuration
- Open User or Workspace Settings and set `"conf.view.showOnWindowOpen": "scm"`
- Refresh the Window. SCM view will be shown always, even if you refresh from a view other than SCM.
- *NOTE*: This setting cannot be applied under Folder settings, doing so will show a warning and value is not respected.
- Run the command `Configure view to show on window open`. Select the value (View to show when opening a window)
- Pick the target `User Settings` or `Workspace Settings` into which the value should be updated
- Value should be updated in selected target
### Testing Resource configuration
- Open User Settings and set `"conf.resource.insertEmptyLastLine": {"${absolute_path_to_file}": true}`
- Open the above configured file in the empty window. A message about adding empty line from the extension is shown.
- Open a different file from one of the root folders. No message is shown.
- Run the command `Configure empty last line for current file`
- Value in Folder Settings of the root folder of the current file is updated. Message is shown now.
- Run the command `Configure empty last line for files` and provide abosoulte path of another file.
- Pick the target `User Settings` or `Workspace Settings` or `Workspace Folder Settings` into which the value should be updated
- Selecting User or Workspace Settings should update the value in respective targets.
- Selecting Workspace Folder Settings will show a Workspace Folder Picker
- Picking a workspace folder should update the value in the respective folder settings file.

View File

@ -28,24 +28,33 @@ export function activate(context: vscode.ExtensionContext) {
// 1) Getting the value
const value = await vscode.window.showQuickPick(['explorer', 'search', 'scm', 'debug', 'extensions'], { placeHolder: 'Select the view to show when opening a window.' });
// 2) Getting the Configuration target
const target = await vscode.window.showQuickPick(
[
{ label: 'User', description: 'User Settings', target: vscode.ConfigurationTarget.Global },
{ label: 'Workspace', description: 'Workspace Settings', target: vscode.ConfigurationTarget.Workspace }
],
{ placeHolder: 'Select the view to show when opening a window.' });
if (vscode.workspace.workspaceFolders) {
if (value && target) {
// 2) Getting the Configuration target
const target = await vscode.window.showQuickPick(
[
{ label: 'User', description: 'User Settings', target: vscode.ConfigurationTarget.Global },
{ label: 'Workspace', description: 'Workspace Settings', target: vscode.ConfigurationTarget.Workspace }
],
{ placeHolder: 'Select the view to show when opening a window.' });
// 3) Update the configuration value in the target
await vscode.workspace.getConfiguration().update('conf.view.showOnWindowOpen', value, target.target);
if (value && target) {
/*
// Default is to update in Workspace
await vscode.workspace.getConfiguration().update('conf.view.showOnWindowOpen', value);
*/
// 3) Update the configuration value in the target
await vscode.workspace.getConfiguration().update('conf.view.showOnWindowOpen', value, target.target);
/*
// Default is to update in Workspace
await vscode.workspace.getConfiguration().update('conf.view.showOnWindowOpen', value);
*/
}
} else {
// 2) Update the configuration value in User Setting in case of no workspace folders
await vscode.workspace.getConfiguration().update('conf.view.showOnWindowOpen', value, vscode.ConfigurationTarget.Global);
}
});
// Example 3: Reading Resource scoped configuration for a file
@ -79,8 +88,10 @@ export function activate(context: vscode.ExtensionContext) {
// 3) Choose target to Global when there are no workspace folders
const target = vscode.workspace.workspaceFolders ? vscode.ConfigurationTarget.WorkspaceFolder : vscode.ConfigurationTarget.Global;
const value = { ...currentValue, ...{ [currentDocument.fileName]: true } };
// 4) Update the configuration
await configuration.update('conf.resource.insertEmptyLastLine', { ...currentValue, ...{ [currentDocument.fileName]: true } }, target)
await configuration.update('conf.resource.insertEmptyLastLine', value, target)
}
});
@ -91,43 +102,62 @@ export function activate(context: vscode.ExtensionContext) {
// 1) Getting the value
const value = await vscode.window.showInputBox({ prompt: 'Provide glob pattern of files to have empty last line.' });
// 2) Getting the target
const target = await vscode.window.showQuickPick(
[
{ label: 'Application', description: 'User Settings', target: vscode.ConfigurationTarget.Global },
{ label: 'Workspace', description: 'Workspace Settings', target: vscode.ConfigurationTarget.Workspace },
{ label: 'Workspace Folder', description: 'Workspace Folder Settings', target: vscode.ConfigurationTarget.WorkspaceFolder }
],
{ placeHolder: 'Select the target to which this setting should be applied' });
if (vscode.workspace.workspaceFolders) {
if (value && target) {
// 2) Getting the target
const target = await vscode.window.showQuickPick(
[
{ label: 'Application', description: 'User Settings', target: vscode.ConfigurationTarget.Global },
{ label: 'Workspace', description: 'Workspace Settings', target: vscode.ConfigurationTarget.Workspace },
{ label: 'Workspace Folder', description: 'Workspace Folder Settings', target: vscode.ConfigurationTarget.WorkspaceFolder }
],
{ placeHolder: 'Select the target to which this setting should be applied' });
if (target.target === vscode.ConfigurationTarget.WorkspaceFolder) {
if (value && target) {
// 3) Getting the workspace folder
let workspaceFolder = await vscode.window.showWorkspaceFolderPick({ placeHolder: 'Pick Workspace Folder to which this setting should be applied' })
if (workspaceFolder) {
if (target.target === vscode.ConfigurationTarget.WorkspaceFolder) {
// 4) Get the configuration for the workspace folder
const configuration = vscode.workspace.getConfiguration('', workspaceFolder.uri);
// 3) Getting the workspace folder
let workspaceFolder = await vscode.window.showWorkspaceFolderPick({ placeHolder: 'Pick Workspace Folder to which this setting should be applied' })
if (workspaceFolder) {
// 5) Get the current value
// 4) Get the configuration for the workspace folder
const configuration = vscode.workspace.getConfiguration('', workspaceFolder.uri);
// 5) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
const newValue = { ...currentValue, ...{ [value]: true } };
// 6) Update the configuration value
await configuration.update('conf.resource.insertEmptyLastLine', newValue, target.target);
}
} else {
// 3) Get the configuration
const configuration = vscode.workspace.getConfiguration();
// 4) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
// 6) Update the configuration value
await configuration.update('conf.resource.insertEmptyLastLine', { ...currentValue, ...{ [value]: true } }, target.target);
const newValue = { ...currentValue, ...{ [value]: true } };
// 3) Update the value in the target
await vscode.workspace.getConfiguration().update('conf.resource.insertEmptyLastLine', newValue, target.target);
}
} else {
// 3) Get the configuration
const configuration = vscode.workspace.getConfiguration();
// 4) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
// 3) Update the value in the target
await vscode.workspace.getConfiguration().update('conf.resource.insertEmptyLastLine', { ...currentValue, ...{ [value]: true } }, target.target);
}
} else {
// 2) Get the configuration
const configuration = vscode.workspace.getConfiguration();
// 3) Get the current value
const currentValue = configuration.get('conf.resource.insertEmptyLastLine');
const newValue = { ...currentValue, ...{ [value]: true } };
// 4) Update the value in the User Settings
await vscode.workspace.getConfiguration().update('conf.resource.insertEmptyLastLine', newValue, vscode.ConfigurationTarget.Global);
}
});