Skip to content

Commit

Permalink
Merge pull request #1560 from Chillee/1369
Browse files Browse the repository at this point in the history
Fixes #1369
  • Loading branch information
johnfn authored Apr 29, 2017
2 parents 024daa5 + fdd3065 commit d1e10ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2206,16 +2206,13 @@ export class ChangeOperator extends BaseOperator {

public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
const isEndOfLine = end.character === end.getLineEnd().character;
const isBeginning =
end.isLineBeginning() &&
!start.isLineBeginning(); // to ensure this is a selection and not e.g. and s command
let state = vimState;

// If we delete to EOL, the block cursor would end on the final character,
// which means the insert cursor would be one to the left of the end of
// the line. We do want to run delete if it is a multiline change though ex. c}
if (Position.getLineLength(TextEditor.getLineAt(start).lineNumber) !== 0 || (end.line !== start.line)) {
if (isEndOfLine || isBeginning) {
if (isEndOfLine) {
state = await new DeleteOperator(this.multicursorIndex).run(vimState, start, end.getLeftThroughLineBreaks());
} else {
state = await new DeleteOperator(this.multicursorIndex).run(vimState, start, end);
Expand Down
8 changes: 8 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ suite("Mode Normal", () => {
endMode: ModeName.Insert
});

newTest({
title: "Can handle 'ci(' across multiple lines with last character at beginning",
start: ['(|a', 'b)'],
keysPressed: 'ci)',
end: ['(|)'],
endMode: ModeName.Insert
});

newTest({
title: "Can handle 'ca(' spanning multiple lines",
start: ['call(', ' |arg1)'],
Expand Down
8 changes: 0 additions & 8 deletions test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,6 @@ suite("Mode Visual", () => {
endMode: ModeName.Normal
});

newTest({
title: "Changes on a firstline selection will not delete first character",
start: ["test|jojo", "haha"],
keysPressed: "vj0c",
end: ["test|haha"],
endMode: ModeName.Insert
});

suite("D command will remove all selected lines", () => {
newTest({
title: "D deletes all selected lines",
Expand Down

0 comments on commit d1e10ad

Please sign in to comment.