Skip to content

Commit

Permalink
Merge pull request #141 from rebornix/Fold
Browse files Browse the repository at this point in the history
add folding command
  • Loading branch information
aioutecism committed Oct 18, 2016
2 parents 3f13b3c + 3468834 commit 49d46dd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Actions/Fold.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {commands} from 'vscode';

export class ActionFold {

static fold(): Thenable<boolean> {
return commands.executeCommand("editor.fold");
}

static unfold(): Thenable<boolean> {
return commands.executeCommand("editor.unfold");
}

static foldAll(): Thenable<boolean> {
return commands.executeCommand("editor.foldAll");
}

static unfoldAll(): Thenable<boolean> {
return commands.executeCommand("editor.unfoldAll");
}
}
5 changes: 5 additions & 0 deletions src/Modes/Normal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {ActionHistory} from '../Actions/History';
import {ActionIndent} from '../Actions/Indent';
import {ActionFilter} from '../Actions/Filter';
import {ActionMode} from '../Actions/Mode';
import {ActionFold} from '../Actions/Fold';
import {MotionCharacter} from '../Motions/Character';
import {MotionLine} from '../Motions/Line';

Expand Down Expand Up @@ -182,6 +183,10 @@ export class ModeNormal extends Mode {

{ keys: 'z .', actions: [ActionReveal.primaryCursor], args: {revealType: TextEditorRevealType.InCenter} },
{ keys: 'z z', actions: [ActionReveal.primaryCursor], args: {revealType: TextEditorRevealType.InCenter} },
{ keys: 'z c', actions: [ActionFold.fold]},
{ keys: 'z o', actions: [ActionFold.unfold]},
{ keys: 'z M', actions: [ActionFold.foldAll]},
{ keys: 'z R', actions: [ActionFold.unfoldAll]},

{ keys: '.', actions: [this.repeatRecordedCommandMaps.bind(this)] },

Expand Down
6 changes: 6 additions & 0 deletions src/Modes/Visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {ActionJoinLines} from '../Actions/JoinLines';
import {ActionFilter} from '../Actions/Filter';
import {ActionFind} from '../Actions/Find';
import {ActionMode} from '../Actions/Mode';
import {ActionFold} from '../Actions/Fold';
import {MotionLine} from '../Motions/Line';

export class ModeVisual extends Mode {
Expand Down Expand Up @@ -84,6 +85,11 @@ export class ModeVisual extends Mode {
{ keys: 'V', actions: [ActionMode.toVisualLine] },
{ keys: 'v', actions: [ActionSelection.shrinkToActives] },

{ keys: 'z c', actions: [ActionFold.fold]},
{ keys: 'z o', actions: [ActionFold.unfold]},
{ keys: 'z M', actions: [ActionFold.foldAll]},
{ keys: 'z R', actions: [ActionFold.unfoldAll]},

{ keys: 'ctrl+c', actions: [ActionSelection.shrinkToActives] },
{ keys: 'ctrl+[', actions: [ActionSelection.shrinkToActives] },
{ keys: 'escape', actions: [ActionSelection.shrinkToActives] },
Expand Down
6 changes: 6 additions & 0 deletions src/Modes/VisualLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {ActionFilter} from '../Actions/Filter';
import {ActionFind} from '../Actions/Find';
import {ActionMode} from '../Actions/Mode';
import {ActionIndent} from '../Actions/Indent';
import {ActionFold} from '../Actions/Fold';
import {MotionLine} from '../Motions/Line';

export class ModeVisualLine extends Mode {
Expand Down Expand Up @@ -85,6 +86,11 @@ export class ModeVisualLine extends Mode {
{ keys: 'v', actions: [ActionMode.toVisual] },
{ keys: 'V', actions: [ActionSelection.shrinkToActives] },

{ keys: 'z c', actions: [ActionFold.fold]},
{ keys: 'z o', actions: [ActionFold.unfold]},
{ keys: 'z M', actions: [ActionFold.foldAll]},
{ keys: 'z R', actions: [ActionFold.unfoldAll]},

{ keys: 'ctrl+c', actions: [ActionSelection.shrinkToActives] },
{ keys: 'ctrl+[', actions: [ActionSelection.shrinkToActives] },
{ keys: 'escape', actions: [ActionSelection.shrinkToActives] },
Expand Down

0 comments on commit 49d46dd

Please sign in to comment.