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

More v8 patches #1766

Merged
merged 3 commits into from
May 27, 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
2 changes: 1 addition & 1 deletion src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export abstract class BaseCommand extends BaseAction {
// begin actions

@RegisterAction
class CommandNumber extends BaseCommand {
export class CommandNumber extends BaseCommand {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine, ModeName.VisualBlock];
keys = ["<number>"];
isCompleteAction = false;
Expand Down
19 changes: 13 additions & 6 deletions src/actions/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Configuration } from './../configuration/configuration';
import {
BaseAction, RegisterAction, compareKeypressSequence
} from './base';
import { CommandNumber } from "./commands/actions";

export class BaseOperator extends BaseAction {
constructor(multicursorIndex?: number) {
Expand Down Expand Up @@ -48,8 +49,9 @@ export class BaseOperator extends BaseAction {
}

public doesRepeatedOperatorApply(vimState: VimState, keysPressed: string[]) {
const prevAction = vimState.recordedState.actionsRun[vimState.recordedState.actionsRun.length - 1];
return this.isOperator && keysPressed.length === 1 && prevAction
const nonCountActions = vimState.recordedState.actionsRun.filter(x => !(x instanceof CommandNumber));
const prevAction = nonCountActions[nonCountActions.length - 1];
return this.isOperator && keysPressed.length === 1 && prevAction
&& this.modes.indexOf(vimState.currentMode) !== -1
// The previous action is the same as the one we're testing
&& prevAction.constructor === this.constructor
Expand Down Expand Up @@ -741,14 +743,18 @@ class ActionVisualReflowParagraph extends BaseOperator {
lines = [``, ``];
}

// This tracks if we're pushing the first line of a chunk. If so, then we
// don't want to add an extra space. In addition, when there's a blank
// line, this needs to be reset.
let curIndex = 0;
for (const line of content.trim().split("\n")) {

// Preserve newlines.

if (line.trim() === "") {
for (let i = 0; i < 2; i++) {
lines.push(``);
}
curIndex = 0;

continue;
}
Expand All @@ -760,15 +766,16 @@ class ActionVisualReflowParagraph extends BaseOperator {
if (word === "") { continue; }

if (lines[lines.length - 1].length + word.length + 1 < maximumLineLength) {
if (i) {
lines[lines.length - 1] += ` ${ word }`;
if (curIndex === 0 && i === 0) {
lines[lines.length - 1] += `${word}`;
} else {
lines[lines.length - 1] += `${ word }`;
lines[lines.length - 1] += ` ${ word }`;
}
} else {
lines.push(`${ word }`);
}
}
curIndex++;
}

if (!commentType.singleLine) {
Expand Down
7 changes: 7 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ suite("Mode Normal", () => {
end: ["one", "two", "|three"],
});

newTest({
title: "Can handle d2d",
start: ['one', 'two', '|three', 'four', 'five'],
keysPressed: 'd2d',
end: ["one", "two", "|five"],
});

newTest({
title: "Can handle dd empty line",
start: ['one', '|', 'two'],
Expand Down