mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Fold commands
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user