File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 "scopeName" : " source.ledger" ,
3636 "path" : " ./syntaxes/ledger.tmLanguage"
3737 }
38+ ],
39+ "commands" : [
40+ {
41+ "command" : " ledger.transactionStatusCycle" ,
42+ "title" : " Cycle Transaction Status"
43+ }
3844 ]
3945 },
4046 "scripts" : {
Original file line number Diff line number Diff line change 1+ import * as vscode from 'vscode' ;
2+ import { transactionStatusCycleHandler } from './transactionCommands' ;
3+
4+ export function registerCommands ( context : vscode . ExtensionContext ) {
5+ const transactionStatusCycleCommand = vscode . commands . registerCommand (
6+ 'ledger.transactionStatusCycle' ,
7+ transactionStatusCycleHandler
8+ ) ;
9+ context . subscriptions . push ( transactionStatusCycleCommand ) ;
10+ }
Original file line number Diff line number Diff line change 1+ import * as vscode from 'vscode' ;
2+
3+ export function transactionStatusCycleHandler ( ) {
4+ const editor = vscode . window . activeTextEditor ;
5+ if ( editor ) {
6+ const currentLine = editor . document . lineAt ( editor . selection . active . line ) ;
7+
8+ if ( currentLine . text . includes ( "!" ) ) {
9+ editor . edit ( editBuilder => {
10+ editBuilder . replace ( currentLine . range , currentLine . text . replace ( "!" , "*" ) ) ;
11+ } ) ;
12+ } else if ( currentLine . text . includes ( "*" ) ) {
13+ editor . edit ( editBuilder => {
14+ editBuilder . replace ( currentLine . range , currentLine . text . replace ( "*" , "!" ) ) ;
15+ } ) ;
16+ }
17+ }
18+ }
Original file line number Diff line number Diff line change 11import * as vscode from 'vscode' ;
22import { LedgerDocumentFormatter } from './formatter' ;
3+ import { registerCommands } from './commands' ;
34
45export function activate ( context : vscode . ExtensionContext ) {
56
67 console . log ( 'Extension "ledger-cli" is now active!' ) ;
78
89 const formatterRegistration = vscode . languages . registerDocumentFormattingEditProvider ( 'ledger' , new LedgerDocumentFormatter ( ) ) ;
910 context . subscriptions . push ( formatterRegistration ) ;
11+
12+ registerCommands ( context ) ;
1013}
1114
1215export function deactivate ( ) { }
You can’t perform that action at this time.
0 commit comments