mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
Add u operator, fix U operator behavior.
This commit is contained in:
parent
0cf7d1892b
commit
8312673f8e
@ -675,12 +675,31 @@ export class UpperCaseOperator extends BaseOperator {
|
||||
public modes = [ModeName.Visual, ModeName.VisualLine];
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
|
||||
end = new Position(end.line, end.character + 1);
|
||||
const range = new vscode.Range(start, new Position(end.line, end.character + 1));
|
||||
let text = vscode.window.activeTextEditor.document.getText(range);
|
||||
|
||||
let text = vscode.window.activeTextEditor.document.getText(new vscode.Range(start, end));
|
||||
await TextEditor.replace(range, text.toUpperCase());
|
||||
|
||||
await TextEditor.replace(new vscode.Range(start, end), text.toUpperCase());
|
||||
vimState.currentMode = ModeName.Normal;
|
||||
vimState.cursorPosition = start;
|
||||
|
||||
return vimState;
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
export class LowerCaseOperator extends BaseOperator {
|
||||
public keys = ["u"];
|
||||
public modes = [ModeName.Visual, ModeName.VisualLine];
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
|
||||
const range = new vscode.Range(start, new Position(end.line, end.character + 1));
|
||||
let text = vscode.window.activeTextEditor.document.getText(range);
|
||||
|
||||
await TextEditor.replace(range, text.toLowerCase());
|
||||
|
||||
vimState.currentMode = ModeName.Normal;
|
||||
vimState.cursorPosition = start;
|
||||
|
||||
return vimState;
|
||||
}
|
||||
|
@ -293,4 +293,18 @@ suite("Mode Normal", () => {
|
||||
keysPressed: ' ',
|
||||
end: ['abc', 'd|ef']
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle u",
|
||||
start: ['|ABC DEF'],
|
||||
keysPressed: 'vwu',
|
||||
end: ['|abc dEF']
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle u over line breaks",
|
||||
start: ['|ABC', 'DEF'],
|
||||
keysPressed: 'vG$u',
|
||||
end: ['|abc', 'def']
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user