Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added :only command and corresponding shortcuts #1882

Merged
merged 1 commit into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { allowVSCodeToPropagateCursorUpdatesAndReturnThem } from '../../util';
import { isTextTransformation } from './../../transformations/transformations';
import { FileCommand } from './../../cmd_line/commands/file';
import { QuitCommand } from './../../cmd_line/commands/quit';
import { OnlyCommand } from './../../cmd_line/commands/only';
import * as vscode from 'vscode';
import * as util from './../../util';
import { RegisterAction } from './../base';
Expand Down Expand Up @@ -2157,6 +2158,18 @@ class CommandQuit extends BaseCommand {
}
}

@RegisterAction
class CommandOnly extends BaseCommand {
modes = [ModeName.Normal];
keys = [["<C-w>", "o"], ["<C-w>", "C-o"]];

public async exec(position: Position, vimState: VimState): Promise<VimState> {
new OnlyCommand({}).execute();

return vimState;
}
}

@RegisterAction
class MoveToRightPane extends BaseCommand {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine];
Expand Down
24 changes: 24 additions & 0 deletions src/cmd_line/commands/only.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

import * as vscode from "vscode";
import * as node from "../node";

export class OnlyCommand extends node.CommandBase {
protected _arguments: {};

constructor(args: {}) {
super();

this._name = 'only';
this._arguments = args;
}

get arguments(): {} {
return this._arguments;
}

async execute(): Promise<void> {
await vscode.commands.executeCommand("workbench.action.closeEditorsInOtherGroups");
return;
}
}
2 changes: 2 additions & 0 deletions src/cmd_line/subparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { parseRegisterCommandArgs } from './subparsers/register';
import { parseDeleteRangeLinesCommandArgs } from './subparsers/deleteRange';
import { parseSortCommandArgs } from './subparsers/sort';
import { parseCloseCommandArgs } from './subparsers/close';
import { parseOnlyCommandArgs } from './subparsers/only';

// maps command names to parsers for said commands.
export const commandParsers = {
Expand Down Expand Up @@ -85,6 +86,7 @@ export const commandParsers = {
vne: fileCmd.parseEditNewFileInNewWindowCommandArgs,
new: fileCmd.parseEditNewFileInNewWindowCommandArgs,
vnew: fileCmd.parseEditNewFileInNewWindowCommandArgs,
only: parseOnlyCommandArgs,

set: parseOptionsCommandArgs,
se: parseOptionsCommandArgs,
Expand Down
7 changes: 7 additions & 0 deletions src/cmd_line/subparsers/only.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

import * as node from "../commands/only";

export function parseOnlyCommandArgs(args: string): node.OnlyCommand {
return new node.OnlyCommand({});
}