-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement :wa[ll] command (write all)
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
import * as vscode from "vscode"; | ||
import * as node from "../node"; | ||
|
||
export interface IWallCommandArguments extends node.ICommandArgs { | ||
bang?: boolean; | ||
range?: node.LineRange; | ||
} | ||
|
||
// | ||
// Implements :wall (write all) | ||
// http://vimdoc.sourceforge.net/htmldoc/editing.html#:wall | ||
// | ||
export class WallCommand extends node.CommandBase { | ||
protected _arguments : IWallCommandArguments; | ||
|
||
constructor(args : IWallCommandArguments) { | ||
super(); | ||
|
||
this._name = 'wall'; | ||
this._shortName = 'wa'; | ||
this._arguments = args; | ||
} | ||
|
||
get arguments() : IWallCommandArguments { | ||
return this._arguments; | ||
} | ||
|
||
async execute() : Promise<void> { | ||
// TODO : ignore untitled documents | ||
// TODO : overwrite readonly files when bang? == true | ||
await vscode.commands.executeCommand('workbench.action.files.saveAll'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use strict"; | ||
|
||
import * as node from "../commands/wall"; | ||
import {Scanner} from '../scanner'; | ||
import {VimError, ErrorCode} from '../../error'; | ||
|
||
export function parseWallCommandArgs(args : string) : node.WallCommand { | ||
if (!args) { | ||
return new node.WallCommand({}); | ||
} | ||
var scannedArgs : node.IWallCommandArguments = {}; | ||
var scanner = new Scanner(args); | ||
const c = scanner.next(); | ||
if (c === '!') { | ||
scannedArgs.bang = true; | ||
scanner.ignore(); | ||
} else if (c !== ' ') { | ||
throw VimError.fromCode(ErrorCode.E488); | ||
} | ||
scanner.skipWhiteSpace(); | ||
if (!scanner.isAtEof) { | ||
throw VimError.fromCode(ErrorCode.E488); | ||
} | ||
return new node.WallCommand(scannedArgs); | ||
} |