diff --git a/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts b/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts
index f549552738b..42c41ecaa8d 100644
--- a/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts
+++ b/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./welcomePage';
+import 'vs/workbench/contrib/welcome/page/browser/vs_code_welcome_page';
import { URI } from 'vs/base/common/uri';
import * as strings from 'vs/base/common/strings';
import { ICommandService } from 'vs/platform/commands/common/commands';
@@ -24,7 +25,6 @@ import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { getInstalledExtensions, IExtensionStatus, onExtensionChanged, isKeymapExtension } from 'vs/workbench/contrib/extensions/common/extensionsUtils';
import { IExtensionManagementService, IExtensionGalleryService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionEnablementService, EnablementState, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
-import { used } from 'vs/workbench/contrib/welcome/page/browser/vs_code_welcome_page';
import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
import { splitName } from 'vs/base/common/labels';
@@ -43,8 +43,6 @@ import { joinPath } from 'vs/base/common/resources';
import { IRecentlyOpened, isRecentWorkspace, IRecentWorkspace, IRecentFolder, isRecentFolder } from 'vs/platform/history/common/history';
import { CancellationToken } from 'vs/base/common/cancellation';
-used();
-
const configurationKey = 'workbench.startupEditor';
const oldConfigurationKey = 'workbench.welcome.enabled';
const telemetryFrom = 'welcomePage';
diff --git a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts b/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts
index 8493b87f2cd..88b60649abd 100644
--- a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts
+++ b/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
+import 'vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough';
import { localize } from 'vs/nls';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Action } from 'vs/base/common/actions';
@@ -17,7 +18,10 @@ const inputOptions: WalkThroughInputOptions = {
typeId,
name: localize('editorWalkThrough.title', "Interactive Playground"),
resource: URI.parse(require.toUrl('./vs_code_editor_walkthrough.md'))
- .with({ scheme: Schemas.walkThrough }),
+ .with({
+ scheme: Schemas.walkThrough,
+ query: JSON.stringify({ moduleId: 'vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough' })
+ }),
telemetryFrom: 'walkThrough'
};
diff --git a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough.md b/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough.ts
similarity index 83%
rename from src/vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough.md
rename to src/vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough.ts
index 1f306f79ef2..53afce0c964 100644
--- a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough.md
+++ b/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/vs_code_editor_walkthrough.ts
@@ -1,3 +1,9 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+export default () => `
## Interactive Editor Playground
The core editor in VS Code is packed with features. This page highlights a number of them and lets you interactively try them out through the use of a number of embedded editors. For full details on the editor features for VS Code and more head over to our [documentation](command:workbench.action.openDocumentationUrl).
@@ -16,34 +22,34 @@ The core editor in VS Code is packed with features. This page highlights a numb
### Multi-Cursor Editing
Using multiple cursors allows you to edit multiple parts of the document at once, greatly improving your productivity. Try the following actions in the code block below:
-1. Box Selection - press
any combination of kb(cursorColumnSelectDown), kb(cursorColumnSelectRight), kb(cursorColumnSelectUp), kb(cursorColumnSelectLeft) to select a block of text. You can also press `โงโฅ``Shift+Alt` while selecting text with the mouse or drag-select using the middle mouse button.
+1. Box Selection - press
any combination of kb(cursorColumnSelectDown), kb(cursorColumnSelectRight), kb(cursorColumnSelectUp), kb(cursorColumnSelectLeft) to select a block of text. You can also press |โงโฅ||Shift+Alt| while selecting text with the mouse or drag-select using the middle mouse button.
2. Add a cursor - press kb(editor.action.insertCursorAbove) to add a new cursor above, or kb(editor.action.insertCursorBelow) to add a new cursor below. You can also use your mouse with
+Click to add a cursor anywhere.
-3. Create cursors on all occurrences of a string - select one instance of a string e.g. `background-color` and press kb(editor.action.selectHighlights). Now you can replace all instances by simply typing.
+3. Create cursors on all occurrences of a string - select one instance of a string e.g. |background-color| and press kb(editor.action.selectHighlights). Now you can replace all instances by simply typing.
That is the tip of the iceberg for multi-cursor editing. Have a look at the selection menu and our handy [keyboard reference guide](command:workbench.action.keybindingsReference) for additional actions.
-```css
+|||css
#p1 {background-color: #ff0000;} /* red in HEX format */
#p2 {background-color: hsl(120, 100%, 50%);} /* green in HSL format */
#p3 {background-color: rgba(0, 4, 255, 0.733);} /* blue with alpha channel in RGBA format */
-```
+|||
-> **CSS Tip:** you may have noticed in the example above we also provide color swatches inline for CSS, additionally if you hover over an element such as `#p1` we will show how this is represented in HTML. These swatches also act as color pickers that allow you to easily change a color value. A simple example of some language-specific editor features.
+> **CSS Tip:** you may have noticed in the example above we also provide color swatches inline for CSS, additionally if you hover over an element such as |#p1| we will show how this is represented in HTML. These swatches also act as color pickers that allow you to easily change a color value. A simple example of some language-specific editor features.
### IntelliSense
Visual Studio Code comes with the powerful IntelliSense for JavaScript and TypeScript pre-installed. In the below example, position the text cursor in front of the error underline, right after the dot and press kb(editor.action.triggerSuggest) to invoke IntelliSense. Notice how the suggestion comes from the Request API.
-```js
+|||js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
- res.send(`Hello ${req.}`);
+ res.send(|Hello \${req.}|);
});
app.listen(3000);
-```
+|||
>**Tip:** while we ship JavaScript and TypeScript support out of the box other languages can be upgraded with better IntelliSense through one of the many [extensions](command:workbench.extensions.action.showPopularExtensions).
@@ -54,22 +60,22 @@ Since it's very common to work with the entire text in a line we provide a set o
2. Move an entire line or selection of lines up or down with kb(editor.action.moveLinesUpAction) and kb(editor.action.moveLinesDownAction) respectively.
3. Delete the entire line with kb(editor.action.deleteLines).
-```json
+|||json
{
- "name": "John",
- "age": 31,
- "city": "New York"
+ "name": "John",
+ "age": 31,
+ "city": "New York"
}
-```
+|||
>**Tip:** Another very common task is to comment out a block of code - you can toggle commenting by pressing kb(editor.action.commentLine).
### Rename Refactoring
-It's easy to rename a symbol such as a function name or variable name. Hit kb(editor.action.rename) while in the symbol `Book` to rename all instances - this will occur across all files in a project. You can also see refactoring in the right-click context menu.
+It's easy to rename a symbol such as a function name or variable name. Hit kb(editor.action.rename) while in the symbol |Book| to rename all instances - this will occur across all files in a project. You can also see refactoring in the right-click context menu.
-```js
+|||js
// Reference the function
new Book("War of the Worlds", "H G Wells");
new Book("The Martian", "Andy Weir");
@@ -84,91 +90,91 @@ function Book(title, author) {
this.title = title;
this.author = author;
}
-```
+|||
-> **JSDoc Tip:** VS Code's IntelliSense uses JSDoc comments to provide richer suggestions. The types and documentation from JSDoc comments show up when you hover over a reference to `Book` or in IntelliSense when you create a new instance of `Book`.
+> **JSDoc Tip:** VS Code's IntelliSense uses JSDoc comments to provide richer suggestions. The types and documentation from JSDoc comments show up when you hover over a reference to |Book| or in IntelliSense when you create a new instance of |Book|.
### Formatting
Keeping your code looking great is hard without a good formatter. Luckily it's easy to format content, either for the entire document with kb(editor.action.formatDocument) or for the current selection with kb(editor.action.formatSelection). Both of these options are also available through the right-click context menu.
-```js
+|||js
const cars = ["๐", "๐", "๐"];
for (const car of cars){
- // Drive the car
- console.log(`This is the car ${car}`);
+ // Drive the car
+ console.log(|This is the car \${car}|);
}
-```
+|||
->**Tip:** Additional formatters are available in the [extension gallery](command:workbench.extensions.action.showPopularExtensions). Formatting support can also be configured via [settings](command:workbench.action.openGlobalSettings) e.g. enabling `editor.formatOnSave`.
+>**Tip:** Additional formatters are available in the [extension gallery](command:workbench.extensions.action.showPopularExtensions). Formatting support can also be configured via [settings](command:workbench.action.openGlobalSettings) e.g. enabling |editor.formatOnSave|.
### Code Folding
In a large file it can often be useful to collapse sections of code to increase readability. To do this, you can simply press kb(editor.fold) to fold or press kb(editor.unfold) to unfold the ranges at the current cursor position. Folding can also be done with the +/- icons in the left gutter. To fold all sections use kb(editor.foldAll) or to unfold all use kb(editor.unfoldAll).
-```html
+|||html
-```
+|||
>**Tip:** Folding is based on indentation and as a result can apply to all languages. Simply indent your code to create a foldable section you can fold a certain number of levels with shortcuts like kb(editor.foldLevel1) through to kb(editor.foldLevel5).
### Errors and Warnings
Errors and warnings are highlighted as you edit your code with squiggles. In the sample below you can see a number of syntax errors. By pressing kb(editor.action.marker.nextInFiles) you can navigate across them in sequence and see the detailed error message. As you correct them the squiggles and scrollbar indicators will update.
-```js
+|||js
// This code has a few syntax errors
Console.log(add(1, 1.5));
function Add(a : Number, b : Number) : Int {
- return a + b;
+ return a + b;
}
-```
+|||
### Snippets
-You can greatly accelerate your editing through the use of snippets. Simply start typing `try` and select `trycatch` from the suggestion list and press kb(insertSnippet) to create a `try`->`catch` block. Your cursor will be placed on the text `error` for easy editing. If more than one parameter exists then press kb(jumpToNextSnippetPlaceholder) to jump to it.
+You can greatly accelerate your editing through the use of snippets. Simply start typing |try| and select |trycatch| from the suggestion list and press kb(insertSnippet) to create a |try|->|catch| block. Your cursor will be placed on the text |error| for easy editing. If more than one parameter exists then press kb(jumpToNextSnippetPlaceholder) to jump to it.
-```js
+|||js
-```
+|||
>**Tip:** the [extension gallery](command:workbench.extensions.action.showPopularExtensions) includes snippets for almost every framework and language imaginable. You can also create your own [user-defined snippets](command:workbench.action.openSnippets).
### Emmet
-Emmet takes the snippets idea to a whole new level: you can type CSS-like expressions that can be dynamically parsed, and produce output depending on what you type in the abbreviation. Try it by selecting `Emmet: Expand Abbreviation` from the `Edit` menu with the cursor at the end of a valid Emmet abbreviation or snippet and the expansion will occur.
+Emmet takes the snippets idea to a whole new level: you can type CSS-like expressions that can be dynamically parsed, and produce output depending on what you type in the abbreviation. Try it by selecting |Emmet: Expand Abbreviation| from the |Edit| menu with the cursor at the end of a valid Emmet abbreviation or snippet and the expansion will occur.
-```html
+|||html
ul>li.item$*5
-```
+|||
->**Tip:** The [Emmet cheat sheet](http://docs.emmet.io/cheat-sheet/) is a great source of Emmet syntax suggestions. To expand Emmet abbreviations and snippets using the `tab` key use the `emmet.triggerExpansionOnTab` [setting](command:workbench.action.openGlobalSettings). Check out the docs on [Emmet in VS Code](https://code.visualstudio.com/docs/editor/emmet) to learn more.
+>**Tip:** The [Emmet cheat sheet](http://docs.emmet.io/cheat-sheet/) is a great source of Emmet syntax suggestions. To expand Emmet abbreviations and snippets using the |tab| key use the |emmet.triggerExpansionOnTab| [setting](command:workbench.action.openGlobalSettings). Check out the docs on [Emmet in VS Code](https://code.visualstudio.com/docs/editor/emmet) to learn more.
### JavaScript Type Checking
-Sometimes type checking your JavaScript code can help you spot mistakes you might have not caught otherwise. You can run the TypeScript type checker against your existing JavaScript code by simply adding a `// @ts-check` comment to the top of your file.
+Sometimes type checking your JavaScript code can help you spot mistakes you might have not caught otherwise. You can run the TypeScript type checker against your existing JavaScript code by simply adding a |// @ts-check| comment to the top of your file.
-```js
+|||js
// @ts-nocheck
let easy = true;
easy = 42;
-```
+|||
->**Tip:** You can also enable the checks workspace or application wide by adding `"javascript.implicitProjectConfig.checkJs": true` to your workspace or user settings and explicitly ignoring files or lines using `// @ts-nocheck` and `// @ts-ignore`. Check out the docs on [JavaScript in VS Code](https://code.visualstudio.com/docs/languages/javascript) to learn more.
+>**Tip:** You can also enable the checks workspace or application wide by adding |"javascript.implicitProjectConfig.checkJs": true| to your workspace or user settings and explicitly ignoring files or lines using |// @ts-nocheck| and |// @ts-ignore|. Check out the docs on [JavaScript in VS Code](https://code.visualstudio.com/docs/languages/javascript) to learn more.
## Thanks!
@@ -180,3 +186,5 @@ Well if you have got this far then you will have touched on some of the editing
That's all for now,
Happy Coding! ๐
+
+`.replace(/\|/g, '`');
diff --git a/src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughContentProvider.ts b/src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughContentProvider.ts
index 49584361d46..05c18b406ab 100644
--- a/src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughContentProvider.ts
+++ b/src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughContentProvider.ts
@@ -6,46 +6,58 @@
import { URI } from 'vs/base/common/uri';
import { ITextModelService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
import { IModelService } from 'vs/editor/common/services/modelService';
-import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
-import { ITextModel, DefaultEndOfLine, EndOfLinePreference, ITextBufferFactory } from 'vs/editor/common/model';
+import { ITextModel, DefaultEndOfLine, EndOfLinePreference } from 'vs/editor/common/model';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import * as marked from 'vs/base/common/marked/marked';
import { Schemas } from 'vs/base/common/network';
import { Range } from 'vs/editor/common/core/range';
+import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
+
+function requireToContent(resource: URI): Promise
{
+ if (!resource.query) {
+ throw new Error('Welcome: invalid resource');
+ }
+
+ const query = JSON.parse(resource.query);
+ if (!query.moduleId) {
+ throw new Error('Welcome: invalid resource');
+ }
+
+ const content: Promise = new Promise((resolve, reject) => {
+ require([query.moduleId], content => {
+ try {
+ resolve(content.default());
+ } catch (err) {
+ reject(err);
+ }
+ });
+ });
+
+ return content;
+}
export class WalkThroughContentProvider implements ITextModelContentProvider, IWorkbenchContribution {
constructor(
@ITextModelService private readonly textModelResolverService: ITextModelService,
- @ITextFileService private readonly textFileService: ITextFileService,
@IModeService private readonly modeService: IModeService,
@IModelService private readonly modelService: IModelService,
) {
this.textModelResolverService.registerTextModelContentProvider(Schemas.walkThrough, this);
}
- public provideTextContent(resource: URI): Promise {
- const query = resource.query ? JSON.parse(resource.query) : {};
- const content: Promise = (query.moduleId ? new Promise((resolve, reject) => {
- require([query.moduleId], content => {
- try {
- resolve(content.default());
- } catch (err) {
- reject(err);
- }
- });
- }) : this.textFileService.readStream(URI.file(resource.fsPath)).then(content => content.value));
- return content.then(content => {
- let codeEditorModel = this.modelService.getModel(resource);
- if (!codeEditorModel) {
- codeEditorModel = this.modelService.createModel(content, this.modeService.createByFilepathOrFirstLine(resource), resource);
- } else {
- this.modelService.updateModel(codeEditorModel, content);
- }
+ public async provideTextContent(resource: URI): Promise {
+ const content = await requireToContent(resource);
- return codeEditorModel;
- });
+ let codeEditorModel = this.modelService.getModel(resource);
+ if (!codeEditorModel) {
+ codeEditorModel = this.modelService.createModel(content, this.modeService.createByFilepathOrFirstLine(resource), resource);
+ } else {
+ this.modelService.updateModel(codeEditorModel, content);
+ }
+
+ return codeEditorModel;
}
}
@@ -53,45 +65,44 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
constructor(
@ITextModelService private readonly textModelResolverService: ITextModelService,
- @ITextFileService private readonly textFileService: ITextFileService,
@IModeService private readonly modeService: IModeService,
@IModelService private readonly modelService: IModelService,
) {
this.textModelResolverService.registerTextModelContentProvider(Schemas.walkThroughSnippet, this);
}
- public provideTextContent(resource: URI): Promise {
- return this.textFileService.readStream(URI.file(resource.fsPath)).then(content => {
- let codeEditorModel = this.modelService.getModel(resource);
- if (!codeEditorModel) {
- const j = parseInt(resource.fragment);
+ public async provideTextContent(resource: URI): Promise {
+ const factory = createTextBufferFactory(await requireToContent(resource));
- let codeSnippet = '';
- let languageName = '';
- let i = 0;
- const renderer = new marked.Renderer();
- renderer.code = (code, lang) => {
- if (i++ === j) {
- codeSnippet = code;
- languageName = lang;
- }
- return '';
- };
+ let codeEditorModel = this.modelService.getModel(resource);
+ if (!codeEditorModel) {
+ const j = parseInt(resource.fragment);
- const textBuffer = content.value.create(DefaultEndOfLine.LF);
- const lineCount = textBuffer.getLineCount();
- const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
- const markdown = textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
- marked(markdown, { renderer });
+ let codeSnippet = '';
+ let languageName = '';
+ let i = 0;
+ const renderer = new marked.Renderer();
+ renderer.code = (code, lang) => {
+ if (i++ === j) {
+ codeSnippet = code;
+ languageName = lang;
+ }
+ return '';
+ };
- const languageId = this.modeService.getModeIdForLanguageName(languageName) || '';
- const languageSelection = this.modeService.create(languageId);
- codeEditorModel = this.modelService.createModel(codeSnippet, languageSelection, resource);
- } else {
- this.modelService.updateModel(codeEditorModel, content.value);
- }
+ const textBuffer = factory.create(DefaultEndOfLine.LF);
+ const lineCount = textBuffer.getLineCount();
+ const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
+ const markdown = textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
+ marked(markdown, { renderer });
- return codeEditorModel;
- });
+ const languageId = this.modeService.getModeIdForLanguageName(languageName) || '';
+ const languageSelection = this.modeService.create(languageId);
+ codeEditorModel = this.modelService.createModel(codeSnippet, languageSelection, resource);
+ } else {
+ this.modelService.updateModel(codeEditorModel, factory);
+ }
+
+ return codeEditorModel;
}
}
diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts
index f84a3a8263f..4285b9a9b90 100644
--- a/src/vs/workbench/workbench.common.main.ts
+++ b/src/vs/workbench/workbench.common.main.ts
@@ -231,6 +231,9 @@ import 'vs/workbench/contrib/watermark/browser/watermark';
// Welcome
import 'vs/workbench/contrib/welcome/overlay/browser/welcomeOverlay';
+import 'vs/workbench/contrib/welcome/page/browser/welcomePage.contribution';
+import 'vs/workbench/contrib/welcome/walkThrough/browser/walkThrough.contribution';
+import 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution';
// Call Hierarchy
import 'vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution';
diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts
index 08920c2cd60..17ba99841f7 100644
--- a/src/vs/workbench/workbench.desktop.main.ts
+++ b/src/vs/workbench/workbench.desktop.main.ts
@@ -134,11 +134,6 @@ import 'vs/workbench/contrib/cli/node/cli.contribution';
// Themes Support
import 'vs/workbench/contrib/themes/test/electron-browser/themes.test.contribution';
-// Welcome
-import 'vs/workbench/contrib/welcome/walkThrough/browser/walkThrough.contribution';
-import 'vs/workbench/contrib/welcome/gettingStarted/electron-browser/gettingStarted.contribution';
-import 'vs/workbench/contrib/welcome/page/browser/welcomePage.contribution';
-
// Issues
import 'vs/workbench/contrib/issue/electron-browser/issue.contribution';