Fold commands

This commit is contained in:
Sandeep Somavarapu
2016-08-29 19:37:16 +02:00
parent fffc1657bc
commit 028ecb30ea
2 changed files with 44 additions and 1 deletions

View File

@ -116,6 +116,11 @@ defineMotionCommand('zt', Motions.RevealCurrentLineAtTop);
defineMotionCommand('zz', Motions.RevealCurrentLineAtCenter);
defineMotionCommand('zb', Motions.RevealCurrentLineAtBottom);
// Folding
defineMotionCommand('zc', Motions.FoldUnder);
defineMotionCommand('zo', Motions.UnfoldUnder);
export interface IFoundOperator {
runNormal(controller: IController, editor:TextEditor): boolean;
runVisual(controller: IController, editor:TextEditor): boolean;

View File

@ -338,6 +338,41 @@ class MoveActiveEditorCommand extends AbstractCommandDescriptor {
};
}
}
class FoldCommand extends AbstractCommandDescriptor {
constructor() {
super();
}
public createCommand(args?: any): Command {
let foldEditorArgs: any = {
levels: args.repeat ? args.repeat : 1,
direction: 'up'
}
return {
commandId: 'editor.fold',
args: foldEditorArgs
};
}
}
class UnfoldCommand extends AbstractCommandDescriptor {
constructor() {
super();
}
public createCommand(args?: any): Command {
let foldEditorArgs: any = {
levels: args.repeat ? args.repeat : 1,
direction: 'up'
}
return {
commandId: 'editor.unfold',
args: foldEditorArgs
};
}
}
export const Motions = {
RightMotion: new RightMotion(),
@ -391,5 +426,8 @@ export const Motions = {
RevealCurrentLineAtTop: new RevealCurrentLineCommand('top'),
RevealCurrentLineAtCenter: new RevealCurrentLineCommand('center'),
RevealCurrentLineAtBottom: new RevealCurrentLineCommand('bottom')
RevealCurrentLineAtBottom: new RevealCurrentLineCommand('bottom'),
FoldUnder: new FoldCommand(),
UnfoldUnder: new UnfoldCommand()
};