├── .todo ├── resources ├── demo.gif ├── logo.png ├── logo.psd └── logo-128x128.png ├── .vscodeignore ├── tsconfig.json ├── src ├── extension.ts ├── config.ts ├── commands.ts ├── utils.ts └── statusbar.ts ├── .gitignore ├── webpack.config.js ├── LICENSE.md ├── CHANGELOG.md ├── README.md └── package.json /.todo: -------------------------------------------------------------------------------- 1 | 2 | ☐ Detect pause status 3 | ☐ https://github.com/Microsoft/vscode/issues/30810 4 | -------------------------------------------------------------------------------- /resources/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/vscode-statusbar-debugger/master/resources/demo.gif -------------------------------------------------------------------------------- /resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/vscode-statusbar-debugger/master/resources/logo.png -------------------------------------------------------------------------------- /resources/logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/vscode-statusbar-debugger/master/resources/logo.psd -------------------------------------------------------------------------------- /resources/logo-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/vscode-statusbar-debugger/master/resources/logo-128x128.png -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | **/*.map 2 | .gitignore 3 | .vscode-test/** 4 | .vscode/** 5 | out/test/** 6 | resources/*.gif 7 | resources/*.psd 8 | src/** 9 | test/** 10 | tsconfig.json 11 | webpack.config.js 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2017", 5 | "outDir": "out", 6 | "lib": ["es2015", "es2016", "es2017"], 7 | "sourceMap": true, 8 | "rootDir": "." 9 | }, 10 | "exclude": [ 11 | "node_modules", 12 | ".vscode-test" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import './statusbar'; 5 | import * as vscode from 'vscode'; 6 | import Utils from './utils'; 7 | 8 | /* ACTIVATE */ 9 | 10 | function activate ( ctx: vscode.ExtensionContext ) { 11 | 12 | return Utils.initCommands ( ctx ); 13 | 14 | } 15 | 16 | /* EXPORT */ 17 | 18 | export {activate}; 19 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import * as vscode from 'vscode'; 5 | 6 | /* CONFIG */ 7 | 8 | const Config = { 9 | 10 | get ( extension = 'statusbarDebugger' ) { 11 | 12 | return vscode.workspace.getConfiguration ().get ( extension ) as any; 13 | 14 | } 15 | 16 | }; 17 | 18 | /* EXPORT */ 19 | 20 | export default Config; 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Numerous always-ignore extensions 2 | *.diff 3 | *.err 4 | *.log 5 | *.orig 6 | *.rej 7 | *.swo 8 | *.swp 9 | *.vi 10 | *.zip 11 | *~ 12 | *.sass-cache 13 | *.ruby-version 14 | *.rbenv-version 15 | 16 | # OS or Editor folders 17 | ._* 18 | .cache 19 | .DS_Store 20 | .idea 21 | .project 22 | .settings 23 | .tmproj 24 | *.esproj 25 | *.sublime-project 26 | *.sublime-workspace 27 | nbproject 28 | Thumbs.db 29 | .fseventsd 30 | .DocumentRevisions* 31 | .TemporaryItems 32 | .Trashes 33 | 34 | # Other paths to ignore 35 | bower_components 36 | node_modules 37 | package-lock.json 38 | out 39 | .vscode-test 40 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | const path = require ( 'path' ); 5 | 6 | /* CONFIG */ 7 | 8 | const config = { 9 | target: 'node', 10 | entry: './src/extension.ts', 11 | output: { 12 | path: path.resolve ( __dirname, 'out' ), 13 | filename: 'extension.js', 14 | libraryTarget: 'commonjs2', 15 | devtoolModuleFilenameTemplate: 'file:///[absolute-resource-path]' 16 | }, 17 | devtool: 'source-map', 18 | externals: { 19 | vscode: 'commonjs vscode', 20 | fsevents: 'commonjs fsevents' 21 | }, 22 | resolve: { 23 | extensions: ['tsx', '.ts', '.jsx', '.js'] 24 | }, 25 | module: { 26 | rules: [{ 27 | test: /\.ts$/, 28 | exclude: /node_modules/, 29 | use: [ 30 | { 31 | loader: 'ts-loader' 32 | } 33 | ] 34 | }] 35 | } 36 | } 37 | 38 | /* EXPORT */ 39 | 40 | module.exports = config; 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-present Fabio Spampinato 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all 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 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/commands.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import * as vscode from 'vscode'; 5 | import Config from './config'; 6 | import Utils from './utils'; 7 | 8 | /* COMMANDS */ 9 | 10 | async function start () { 11 | 12 | const config = Config.get (); 13 | 14 | if ( config.command === 'start' ) { 15 | 16 | vscode.commands.executeCommand ( 'workbench.action.debug.start' ); 17 | 18 | } else if ( config.command === 'select' ) { 19 | 20 | vscode.commands.executeCommand ( 'workbench.action.debug.selectandstart' ); 21 | 22 | } else if ( config.command === 'auto' ) { 23 | 24 | try { 25 | 26 | await vscode.commands.executeCommand ( 'debugLauncher.auto' ); 27 | 28 | } catch ( e ) { 29 | 30 | const nr = await Utils.getLaunchConfigurationsNr (); 31 | 32 | if ( !nr ) { 33 | 34 | vscode.commands.executeCommand ( 'debug.addConfiguration' ); 35 | 36 | } else if ( nr === 1 ){ 37 | 38 | vscode.commands.executeCommand ( 'workbench.action.debug.start' ); 39 | 40 | } else if ( nr > 1 ) { 41 | 42 | vscode.commands.executeCommand ( 'workbench.action.debug.selectandstart' ); 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | async function stop () { 53 | 54 | vscode.commands.executeCommand ( 'workbench.action.debug.stop' ); 55 | 56 | } 57 | 58 | async function restart () { 59 | 60 | try { 61 | 62 | await vscode.commands.executeCommand ( 'debugLauncher.auto' ); 63 | 64 | } catch ( e ) { 65 | 66 | vscode.commands.executeCommand ( 'workbench.action.debug.restart' ); 67 | 68 | } 69 | 70 | } 71 | 72 | /* EXPORT */ 73 | 74 | export {start, stop, restart}; 75 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### Version 2.0.7 2 | - Update .github/FUNDING.yml 3 | - Deleted repo-level github funding.yml 4 | - Minor improvements to the used icons 5 | 6 | ### Version 2.0.6 7 | - Improved description of the “statusbarDebugger.command” setting 8 | 9 | ### Version 2.0.5 10 | - Fixed a regression regarding detecting existing launch configurations 11 | 12 | ### Version 2.0.4 13 | - Properly restarting debuggers launched via Debug Launcher 14 | 15 | ### Version 2.0.3 16 | - Readme: using hi-res logo 17 | 18 | ### Version 2.0.2 19 | - Outputting modern code (es2017, faster) 20 | - Using "Debug Launcher" for debugging 21 | 22 | ### Version 2.0.1 23 | - Properly detecting if “Debug Launcher” is installed 24 | 25 | ### Version 2.0.0 26 | - Added support for “Debug Launcher” 27 | 28 | ### Version 1.4.5 29 | - Fixed a regression 30 | 31 | ### Version 1.4.4 32 | - Bundling with webpack 33 | 34 | ### Version 1.4.3 35 | - Readme: updated hint for disabling the floating debugger 36 | 37 | ### Version 1.4.2 38 | - Ensuring all instances of each token get replaced 39 | 40 | ### Version 1.4.1 41 | - Improved active session detection 42 | 43 | ### Version 1.4.0 44 | - Support for changing the icon of each action 45 | 46 | ### Version 1.3.3 47 | - Updated readme 48 | 49 | ### Version 1.3.2 50 | - Readme: added an hint about the debug launcher 51 | 52 | ### Version 1.3.1 53 | - Fixed a typo 54 | 55 | ### Version 1.3.0 56 | - Added support for disabling some or all actions 57 | - Added a `template` setting 58 | - Added support for displaying the name of the current debugging session 59 | - Added a `command `option 60 | - Added support for a smart `auto` command 61 | - Watching `launch.json` for changes 62 | 63 | ### Version 1.2.0 64 | - Added options for customizing alignment and priority 65 | 66 | ### Version 1.1.2 67 | - Improved support for `Start Without Debugging` 68 | 69 | ### Version 1.1.1 70 | - Updated readme 71 | 72 | ### Version 1.1.0 73 | - Auto-detection of start/stop events 74 | 75 | ### Version 1.0.2 76 | - Added a `pause` action button 77 | 78 | ### Version 1.0.2 79 | - Added a setting for changed the bug's color when active 80 | 81 | ### Version 1.0.1 82 | - Changed bug's color when active 83 | 84 | ### Version 1.0.0 85 | - Initial release 86 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | 2 | /* IMPORT */ 3 | 4 | import * as _ from 'lodash'; 5 | import * as absolute from 'absolute'; 6 | import * as fs from 'fs'; 7 | import * as JSON5 from 'json5'; 8 | import * as path from 'path'; 9 | import * as pify from 'pify'; 10 | import * as vscode from 'vscode'; 11 | import * as Commands from './commands'; 12 | 13 | /* UTILS */ 14 | 15 | const Utils = { 16 | 17 | initCommands ( context: vscode.ExtensionContext ) { 18 | 19 | const {commands} = vscode.extensions.getExtension ( 'fabiospampinato.vscode-statusbar-debugger' ).packageJSON.contributes; 20 | 21 | commands.forEach ( ({ command }) => { 22 | 23 | const commandName = _.last ( command.split ( '.' ) ) as string, 24 | handler = Commands[commandName], 25 | disposable = vscode.commands.registerCommand ( command, () => handler () ); 26 | 27 | context.subscriptions.push ( disposable ); 28 | 29 | }); 30 | 31 | return Commands; 32 | 33 | }, 34 | 35 | async getLaunchConfigurationsNr () { 36 | 37 | const rootPath = Utils.folder.getActiveRootPath () as string; //TSC 38 | 39 | if ( !rootPath ) return 0; 40 | 41 | const launchPath = path.join ( rootPath, '.vscode', 'launch.json' ); 42 | 43 | if ( !launchPath ) return 0; 44 | 45 | const content = await Utils.file.read ( launchPath ); 46 | 47 | if ( !content ) return 0; 48 | 49 | const contentj = _.attempt ( JSON5.parse, content ) as any; //TSC 50 | 51 | if ( _.isError ( contentj ) ) return 0; 52 | 53 | const {configurations} = contentj; 54 | 55 | if ( !_.isArray ( configurations ) ) return 0; 56 | 57 | return configurations.length; 58 | 59 | }, 60 | 61 | file: { 62 | 63 | async read ( filepath ) { 64 | 65 | try { 66 | return ( await pify ( fs.readFile )( filepath, { encoding: 'utf8' } ) ).toString (); 67 | } catch ( e ) { 68 | return; 69 | } 70 | 71 | } 72 | 73 | }, 74 | 75 | folder: { 76 | 77 | getRootPath ( basePath? ) { 78 | 79 | const {workspaceFolders} = vscode.workspace; 80 | 81 | if ( !workspaceFolders ) return; 82 | 83 | const firstRootPath = workspaceFolders[0].uri.fsPath; 84 | 85 | if ( !basePath || !absolute ( basePath ) ) return firstRootPath; 86 | 87 | const rootPaths = workspaceFolders.map ( folder => folder.uri.fsPath ), 88 | sortedRootPaths = _.sortBy ( rootPaths, [path => path.length] ).reverse (); // In order to get the closest root 89 | 90 | return sortedRootPaths.find ( rootPath => basePath.startsWith ( rootPath ) ); 91 | 92 | }, 93 | 94 | getActiveRootPath () { 95 | 96 | const {activeTextEditor} = vscode.window, 97 | editorPath = activeTextEditor && activeTextEditor.document.uri.fsPath; 98 | 99 | return Utils.folder.getRootPath ( editorPath ); 100 | 101 | } 102 | 103 | } 104 | 105 | }; 106 | 107 | /* EXPORT */ 108 | 109 | export default Utils; 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StatusBar Debugger 2 | 3 |
4 |
5 |