From f2c7fdefeacedae4553ad0389c952044fb6eaf50 Mon Sep 17 00:00:00 2001 From: rebornix Date: Sun, 16 Oct 2016 21:50:17 -0700 Subject: [PATCH 1/3] add folding command --- src/Actions/Fold.ts | 21 +++++++++++++++++++++ src/Modes/Normal.ts | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 src/Actions/Fold.ts diff --git a/src/Actions/Fold.ts b/src/Actions/Fold.ts new file mode 100644 index 00000000..aad1860a --- /dev/null +++ b/src/Actions/Fold.ts @@ -0,0 +1,21 @@ +import {commands} from 'vscode'; +import {ActionSelection} from './Selection'; + +export class ActionFold { + + static fold(): Thenable { + return commands.executeCommand("editor.fold"); + } + + static unfold(): Thenable { + return commands.executeCommand("editor.unfold"); + } + + static foldAll(): Thenable { + return commands.executeCommand("editor.foldAll"); + } + + static unfoldAll(): Thenable { + return commands.executeCommand("editor.unfoldAll"); + } +} \ No newline at end of file diff --git a/src/Modes/Normal.ts b/src/Modes/Normal.ts index 7f5cdb34..85112a57 100644 --- a/src/Modes/Normal.ts +++ b/src/Modes/Normal.ts @@ -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'; @@ -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)] }, From ff8d8810eae157ce6a76125a8e7e58bb4538c965 Mon Sep 17 00:00:00 2001 From: rebornix Date: Sun, 16 Oct 2016 22:14:28 -0700 Subject: [PATCH 2/3] remove unused variables --- src/Actions/Fold.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Actions/Fold.ts b/src/Actions/Fold.ts index aad1860a..de3074e0 100644 --- a/src/Actions/Fold.ts +++ b/src/Actions/Fold.ts @@ -1,5 +1,4 @@ import {commands} from 'vscode'; -import {ActionSelection} from './Selection'; export class ActionFold { @@ -18,4 +17,4 @@ export class ActionFold { static unfoldAll(): Thenable { return commands.executeCommand("editor.unfoldAll"); } -} \ No newline at end of file +} From 3468834a6ea8e852449c0a0ba0d6fbae42fcb4ce Mon Sep 17 00:00:00 2001 From: rebornix Date: Mon, 17 Oct 2016 08:34:10 -0700 Subject: [PATCH 3/3] add fold support for visual and visualline mode --- src/Modes/Visual.ts | 6 ++++++ src/Modes/VisualLine.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Modes/Visual.ts b/src/Modes/Visual.ts index 9952640b..a599ddac 100644 --- a/src/Modes/Visual.ts +++ b/src/Modes/Visual.ts @@ -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 { @@ -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] }, diff --git a/src/Modes/VisualLine.ts b/src/Modes/VisualLine.ts index 4f1145f7..882f0f1d 100644 --- a/src/Modes/VisualLine.ts +++ b/src/Modes/VisualLine.ts @@ -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 { @@ -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] },