├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── assets └── example.gif ├── package-lock.json ├── package.json ├── src ├── extension.ts ├── run-code.ts ├── settings.ts └── test │ ├── run-test.ts │ ├── suite │ ├── extension.test.ts │ └── index.ts │ └── unit │ └── unit-test.ts ├── tsconfig.json └── vsc-extension-quickstart.md /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | .vscode-test/ 4 | *.vsix 5 | *.js 6 | *.js.map 7 | vscode.d.ts 8 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 11 | "stopOnEntry": false, 12 | "sourceMaps": true, 13 | "outFiles": [ "${workspaceRoot}/out/src/**/*.js" ], 14 | "preLaunchTask": "npm" 15 | }, 16 | { 17 | "name": "Launch Tests", 18 | "type": "extensionHost", 19 | "request": "launch", 20 | "runtimeExecutable": "${execPath}", 21 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ], 22 | "stopOnEntry": false, 23 | "sourceMaps": true, 24 | "outFiles": [ "${workspaceRoot}/out/test/**/*.js" ], 25 | "preLaunchTask": "npm" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | } 9 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls a custom npm script that compiles the extension. 10 | { 11 | "version": "2.0.0", 12 | 13 | // we want to run npm 14 | "command": "npm", 15 | 16 | // we run the custom script "compile" as defined in package.json 17 | "args": ["run", "watch", "--loglevel", "silent"], 18 | 19 | // The tsc compiler is started in watching mode 20 | "isBackground": true, 21 | 22 | // use the standard tsc in watch mode problem matcher to find compile problems in the output. 23 | "problemMatcher": "$tsc-watch", 24 | "tasks": [ 25 | { 26 | "label": "npm", 27 | "type": "shell", 28 | "command": "npm", 29 | "args": [ 30 | "run", 31 | "watch", 32 | "--loglevel", 33 | "silent" 34 | ], 35 | "isBackground": true, 36 | "problemMatcher": "$tsc-watch", 37 | "group": { 38 | "_id": "build", 39 | "isDefault": false 40 | } 41 | } 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | test/** 5 | src/** 6 | **/*.map 7 | .gitignore 8 | tsconfig.json 9 | vsc-extension-quickstart.md 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.2.0 - 2022-12-07 4 | 5 | - Prefer selection instead of inferred code block if selection is non-empty https://github.com/kylebarron/vscode-jupyter-python/pull/5 6 | - Scroll down when setting selection https://github.com/kylebarron/vscode-jupyter-python/pull/4 7 | 8 | ## 0.1.0 - 2022-11-28 9 | 10 | Initial release. 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Kyle Barron 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vscode-jupyter-python README 2 | 3 | Run automatically-inferred Python code blocks in Jupyter. 4 | 5 | In this example, the **only** keyboard shortcut used is Shift+Enter: 6 | 7 | ![](https://user-images.githubusercontent.com/15164633/204451326-5ac2e334-6127-4f00-be93-4d0041405e98.gif) 8 | 9 | This is inspired by the [Hydrogen](https://github.com/nteract/hydrogen) and [`hydrogen-python`](https://github.com/nikitakit/hydrogen-python) extensions for [Atom](https://github.com/atom/atom/). 10 | 11 | ## Install 12 | 13 | Install from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=kylebarron.vscode-jupyter-python) or search `kylebarron.vscode-jupyter-python` in the vscode extensions search bar. 14 | 15 | ## Features 16 | 17 | - Infer a logical "block" of code to be run at once, without needing to manually mark cell boundaries with `# %%`. 18 | 19 | In general a "block" is the current line plus any following lines with a greater initial indentation. 20 | 21 | _Additionally_ there's a list of keywords where the "block" of code should be expanded, even when that code appears at the same indentation level. For example: 22 | 23 | ```py 24 | # cursor 25 | # ↓ 26 | if x > 0: 27 | foo() 28 | else: 29 | bar() 30 | ``` 31 | 32 | in this case a naive "include only code with greater indentation" would exclude the `else` clause, so `else` is included in the list of keywords where the code should be extended despite being at the initial indentation. See "extension settings" below for how to modify this list. 33 | 34 | ## Keyboard Shortcuts 35 | 36 | By default there are two shortcuts defined: 37 | 38 | - Cmd+Enter/Ctrl+Enter: Run an automatically-inferred code block but don't move the cursor. 39 | - Shift+Enter: Run an automatically-inferred code block and move the cursor down to the start of the next code block. 40 | 41 | ## Requirements 42 | 43 | This depends on the upstream [`vscode-jupyter`](https://github.com/microsoft/vscode-jupyter) extension, where this extension simply infers what text to send to `jupyter.execSelectionInteractive`. 44 | 45 | ## Extension Settings 46 | 47 | - `vscode-jupyter-python.expandCodeList`: This list is used to determine when code that is part of the same indentation level as the starting text should be included in the inferred block. You may define your own custom elements to modify the code to your preferred behaviour. In the default setting, `else`, `elif`, `except`, `finally`, as well as all closing braces are expanded on. 48 | 49 | ## Known Issues 50 | 51 | This is an early package so there are probably bugs. 52 | 53 | - [ ] Support for extending block upwards (i.e. if a decorator is on the previous line, include it in the current selection) 54 | -------------------------------------------------------------------------------- /assets/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebarron/vscode-jupyter-python/1f3a196dffd8ecd746dada7cbdc71be9716aded3/assets/example.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-jupyter-python", 3 | "displayName": "vscode-jupyter-python", 4 | "description": "Run automatically-inferred Python code blocks in Jupyter.", 5 | "version": "0.2.0", 6 | "publisher": "kylebarron", 7 | "repository": "https://github.com/kylebarron/vscode-jupyter-python", 8 | "engines": { 9 | "vscode": "^1.54.0" 10 | }, 11 | "license": "MIT", 12 | "categories": [ 13 | "Other" 14 | ], 15 | "activationEvents": [ 16 | "onCommand:vscode-jupyter-python.run-inferred-block", 17 | "onCommand:vscode-jupyter-python.run-inferred-block-and-move-down" 18 | ], 19 | "main": "./out/extension", 20 | "contributes": { 21 | "commands": [ 22 | { 23 | "command": "vscode-jupyter-python.run-inferred-block", 24 | "title": "Jupyter Python: Run inferred code block" 25 | }, 26 | { 27 | "command": "vscode-jupyter-python.run-inferred-block-and-move-down", 28 | "title": "Jupyter Python: Run inferred code block and move down" 29 | } 30 | ], 31 | "configuration": { 32 | "title": "vscode-jupyter-python", 33 | "properties": { 34 | "vscode-jupyter-python.expandCodeList": { 35 | "title": "Code to Expand", 36 | "type": "array", 37 | "items": { 38 | "type": "string" 39 | }, 40 | "default": [ 41 | "else", 42 | "elif", 43 | "except", 44 | "finally", 45 | "\\}", 46 | "\\]", 47 | "\\)" 48 | ], 49 | "description": "This list is used to determine when code that is part of the same indentation level as the starting text should be included in the inferred block. You may define your own custom elements to modify the code to your preferred behaviour. In the default setting, else, elif, except, finally, as well as all closing braces are expanded on." 50 | } 51 | } 52 | }, 53 | "keybindings": [ 54 | { 55 | "command": "vscode-jupyter-python.run-inferred-block", 56 | "key": "ctrl+enter", 57 | "mac": "cmd+enter", 58 | "when": "editorTextFocus && editorLangId == python && !findInputFocussed && !replaceInputFocussed && jupyter.ownsSelection && !notebookEditorFocused" 59 | }, 60 | { 61 | "command": "vscode-jupyter-python.run-inferred-block-and-move-down", 62 | "key": "shift+enter", 63 | "when": "editorTextFocus && editorLangId == python && !findInputFocussed && !replaceInputFocussed && jupyter.ownsSelection && !notebookEditorFocused" 64 | } 65 | ] 66 | }, 67 | "extensionDependencies": [ 68 | "ms-toolsai.jupyter" 69 | ], 70 | "scripts": { 71 | "compile": "tsc -p ./", 72 | "download-api": "vscode-dts dev", 73 | "lint": "eslint \"src/**/*.ts\"", 74 | "postdownload-api": "vscode-dts main", 75 | "postinstall": "npm run download-api", 76 | "pretest": "npm run compile", 77 | "test": "node ./out/test/run-test.js", 78 | "unit-test": "npm run compile && mocha ./out/test/unit", 79 | "vscode:prepublish": "npm run compile", 80 | "watch": "tsc -watch -p ./" 81 | }, 82 | "devDependencies": { 83 | "@types/glob": "^7.1.1", 84 | "@types/mocha": "^5.2.6", 85 | "@types/node": "^16.11.7", 86 | "@types/vscode": "^1.54.0", 87 | "@typescript-eslint/eslint-plugin": "^5.42.0", 88 | "@typescript-eslint/parser": "^5.42.0", 89 | "@vscode/test-electron": "^1.6.1", 90 | "eslint": "^8.26.0", 91 | "glob": "^7.1.4", 92 | "mocha": "^6.1.4", 93 | "source-map-support": "^0.5.12", 94 | "typescript": "^4.8.4", 95 | "vscode-dts": "^0.3.2", 96 | "yo": "^4.3.1" 97 | }, 98 | "dependencies": {} 99 | } 100 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // The module 'vscode' contains the VS Code extensibility API 3 | // Import the module and reference it with the alias vscode in your code below 4 | import * as vscode from "vscode"; 5 | import { 6 | runInferredCodeBlock, 7 | runInferredCodeBlockAndMoveDown, 8 | } from "./run-code"; 9 | 10 | // this method is called when your extension is activated 11 | // your extension is activated the very first time the command is executed 12 | export function activate(context: vscode.ExtensionContext) { 13 | // Use the console to output diagnostic information (console.log) and errors (console.error) 14 | // This line of code will only be executed once when your extension is activated 15 | console.log( 16 | 'Congratulations, your extension "vscode-jupyter-python" is now active!' 17 | ); 18 | 19 | // The command has been defined in the package.json file 20 | // Now provide the implementation of the command with registerCommand 21 | // The commandId parameter must match the command field in package.json 22 | let disposable1 = vscode.commands.registerCommand( 23 | "vscode-jupyter-python.run-inferred-block", 24 | async () => runInferredCodeBlock() 25 | ); 26 | 27 | let disposable2 = vscode.commands.registerCommand( 28 | "vscode-jupyter-python.run-inferred-block-and-move-down", 29 | async () => runInferredCodeBlockAndMoveDown() 30 | ); 31 | 32 | context.subscriptions.push(disposable1); 33 | context.subscriptions.push(disposable2); 34 | } 35 | 36 | // this method is called when your extension is deactivated 37 | export function deactivate() {} 38 | -------------------------------------------------------------------------------- /src/run-code.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { Range, Position, TextEditor, Selection } from "vscode"; 3 | import { getExpandCodeList } from "./settings"; 4 | 5 | export function runEntireFile() { 6 | const textEditor = vscode.window.activeTextEditor; 7 | const document = textEditor?.document; 8 | const text = document?.getText(); 9 | vscode.commands.executeCommand("jupyter.execSelectionInteractive", text); 10 | } 11 | 12 | /** 13 | * Run an inferred code block in the IPython kernel 14 | */ 15 | export function runInferredCodeBlock(): void { 16 | const textEditor = vscode.window.activeTextEditor; 17 | if (!textEditor) { 18 | return; 19 | } 20 | 21 | const expandedCodeRange = inferCodeBlock(textEditor); 22 | const inferredBlockText = textEditor.document.getText(expandedCodeRange); 23 | executeText(inferredBlockText); 24 | } 25 | 26 | export function runInferredCodeBlockAndMoveDown(): void { 27 | const textEditor = vscode.window.activeTextEditor; 28 | if (!textEditor) { 29 | return; 30 | } 31 | 32 | const expandedCodeRange = inferCodeBlock(textEditor); 33 | const inferredBlockText = textEditor.document.getText(expandedCodeRange); 34 | executeText(inferredBlockText); 35 | 36 | const endPosition = new Position(expandedCodeRange.end.line + 1, 0); 37 | const newSelection = new Selection(endPosition, endPosition); 38 | setSelectionAndMoveDown(textEditor, newSelection); 39 | } 40 | 41 | function inferCodeBlock(textEditor: TextEditor): Range { 42 | const initialSelection = textEditor.selection; 43 | 44 | return initialSelection.isEmpty 45 | ? getExpandedCodeRegion(textEditor) 46 | : new Range(initialSelection.start, initialSelection.end); 47 | } 48 | 49 | /** Set selection in given text editor and scroll down */ 50 | function setSelectionAndMoveDown( 51 | textEditor: TextEditor, 52 | selection: Selection 53 | ): void { 54 | textEditor.selections = [selection]; 55 | textEditor.revealRange(selection); 56 | } 57 | 58 | function executeText(text: string): void { 59 | vscode.commands.executeCommand("jupyter.execSelectionInteractive", text); 60 | } 61 | 62 | function movePositionToStartOfLine(position: Position): Position { 63 | return position.with(undefined, 0); 64 | } 65 | 66 | function getExpandedCodeRegion(editor: TextEditor): Range { 67 | // When inferring an expanded code range, always start at the beginning of a line 68 | const initialPosition = movePositionToStartOfLine(editor.selection.anchor); 69 | 70 | // Assuming that no text is selected 71 | // In practice, initialPosition here is the beginning of a line 72 | const beginRange = new Range(initialPosition, initialPosition); 73 | console.log("beginRange", beginRange); 74 | 75 | const initialIndentText = getInitialIndentTextAtLine(editor, initialPosition); 76 | console.log("initialIndentText", initialIndentText); 77 | 78 | const finalRange = expandRangeDownward(editor, beginRange, initialIndentText); 79 | console.log("finalRange", finalRange); 80 | return finalRange; 81 | } 82 | 83 | function getInitialIndentTextAtLine( 84 | editor: TextEditor, 85 | initialPosition: Position 86 | ): string { 87 | const lineText = editor.document.lineAt(initialPosition.line).text; 88 | const indent = lineText.match(/^\s+/); 89 | return indent ? indent[0] : ""; 90 | } 91 | 92 | /** 93 | * Expand range downwards 94 | * 95 | * @param editor [editor description] 96 | * @param range Starting Range 97 | * @param indent Indentation of original line 98 | * 99 | * @return {Range} [return description] 100 | */ 101 | function expandRangeDownward( 102 | editor: TextEditor, 103 | currentRange: Range, 104 | indent: string 105 | ): Range { 106 | const document = editor.document; 107 | const expandCodeList = getExpandCodeList(); 108 | // add whitespace to the list 109 | const expandCode = ["\\s"].concat(expandCodeList).join("|"); 110 | const expandRegex = new RegExp(`^(${indent}(${expandCode})|\s*#|\s*$)`); 111 | 112 | const whitespaceOnlyRegex = new RegExp("^\\s*$"); 113 | 114 | let nextLineNum = currentRange.end.line + 1; 115 | 116 | // expand code to the bottom 117 | while ( 118 | nextLineNum < editor.document.lineCount && 119 | (document.lineAt(nextLineNum).text.match(whitespaceOnlyRegex) || 120 | document.lineAt(nextLineNum).text.match(expandRegex)) 121 | ) { 122 | nextLineNum += 1; 123 | console.log("adding a line number:", nextLineNum); 124 | } 125 | 126 | console.log("nextLineNum", nextLineNum); 127 | 128 | const endPosition = document.lineAt(nextLineNum - 1).range.end; 129 | console.log("endPosition", endPosition); 130 | const endRange = new Range(currentRange.start, endPosition); 131 | console.log("endRange", endRange); 132 | return endRange; 133 | } 134 | 135 | -------------------------------------------------------------------------------- /src/settings.ts: -------------------------------------------------------------------------------- 1 | import { workspace } from "vscode"; 2 | 3 | export function getExpandCodeList(): string[] { 4 | const config = workspace.getConfiguration("vscode-jupyter-python"); 5 | const expandCodeList = config.get("expandCodeList", []); 6 | return expandCodeList; 7 | } 8 | -------------------------------------------------------------------------------- /src/test/run-test.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to the extension test script 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | // 2 | // Note: This example test is leveraging the Mocha test framework. 3 | // Please refer to their documentation on https://mochajs.org/ for help. 4 | // 5 | 6 | // The module 'assert' provides assertion methods from node 7 | import * as assert from 'assert'; 8 | 9 | // You can import and use all API from the 'vscode' module 10 | // as well as import your extension to test it 11 | import * as vscode from 'vscode'; 12 | 13 | // import * as myExtension from '../../extension'; 14 | 15 | // Defines a Mocha test suite to group tests of similar kind together 16 | suite("Extension Tests", () => { 17 | 18 | // Defines a Mocha unit test 19 | test("Something 1", () => { 20 | assert.equal(-1, [1, 2, 3].indexOf(5)); 21 | assert.equal(-1, [1, 2, 3].indexOf(0)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import * as Mocha from "mocha"; 3 | import * as glob from "glob"; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: "tdd", 9 | }); 10 | mocha.useColors(true); 11 | 12 | const testsRoot = path.resolve(__dirname, ".."); 13 | 14 | return new Promise((c, e) => { 15 | glob("**/**.test.js", { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run((failures) => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /src/test/unit/unit-test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from "assert"; 2 | import { suite, test } from "mocha"; 3 | 4 | suite("Extension Tests", () => { 5 | // Defines a Mocha unit test 6 | test("Something 1", () => { 7 | assert.equal(-1, [1, 2, 3].indexOf(5)); 8 | assert.equal(-1, [1, 2, 3].indexOf(0)); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2020", 5 | "lib": ["es2020"], 6 | "outDir": "out", 7 | "sourceMap": true, 8 | "strict": true, 9 | "rootDir": "src" 10 | }, 11 | "exclude": ["node_modules", ".vscode-test"] 12 | } 13 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your first VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | - This folder contains all of the files necessary for your extension 6 | - `package.json` - this is the manifest file in which you declare your extension and command. 7 | The sample plugin registers a command and defines its title and command name. With this information 8 | VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 9 | - `src/extension.ts` - this is the main file where you will provide the implementation of your command. 10 | The file exports one function, `activate`, which is called the very first time your extension is 11 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 12 | We pass the function containing the implementation of the command as the second parameter to 13 | `registerCommand`. 14 | 15 | ## Get up and running straight away 16 | 17 | - press `F5` to open a new window with your extension loaded 18 | - run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World` 19 | - set breakpoints in your code inside `src/extension.ts` to debug your extension 20 | - find output from your extension in the debug console 21 | 22 | ## Make changes 23 | 24 | - you can relaunch the extension from the debug toolbar after changing code in `src/extension.ts` 25 | - you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes 26 | 27 | ## Explore the API 28 | 29 | - you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts` 30 | 31 | ## Run tests 32 | 33 | - open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests` 34 | - press `F5` to run the tests in a new window with your extension loaded 35 | - see the output of the test result in the debug console 36 | - make changes to `test/extension.test.ts` or create new test files inside the `test` folder 37 | - by convention, the test runner will only consider files matching the name pattern `**.test.ts` 38 | - you can create folders inside the `test` folder to structure your tests any way you want 39 | --------------------------------------------------------------------------------