Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Chillee committed Apr 28, 2017
1 parent c57d370 commit 403720a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2929,9 +2929,21 @@ class CommandClearLine extends BaseCommand {
runsOnceForEachCountPrefix = false;

public async exec(position: Position, vimState: VimState): Promise<VimState> {
let count = vimState.recordedState.count || 1;
let end = position.getDownByCount(Math.max(0, count - 1)).getLineEnd().getLeft();
return new ChangeOperator().run(vimState, position.getLineBeginRespectingIndent(), end);
let indentLine = position;
do {
indentLine = indentLine.getUp(1);
} while (indentLine.getLineEnd().character === 0 && indentLine.getDocumentBegin().line !== indentLine.line);
let indentLevel = TextEditor.getIndentationLevel(TextEditor.getLineAt(indentLine).text);
vimState.recordedState.transformations.push({
type: "replaceText",
text: TextEditor.setIndentationLevel("", indentLevel),
start: position.getLineBegin(),
end: position.getLineEnd(),
manuallySetCursorPositions: true
});
vimState.currentMode = ModeName.Insert;
vimState.cursorPosition = new Position(position.line, indentLevel);
return vimState;
}
}

Expand Down

0 comments on commit 403720a

Please sign in to comment.