-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add yank support for Visual mode (#217)
* add setNormal to ModeHandler This allows safe switching to Normal mode * add copy to TextEditor class This allows to copy a selection to the clipboard. The clipboard is handled by the copy-paste package that was already a dependency. * add yank operator This allows to yank selected text in visual mode. * Remove unused import * Add missing semicolon
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
|
||
import * as vscode from "vscode"; | ||
import { Position } from './../motion/position'; | ||
import { Operator } from './operator'; | ||
import { ModeHandler } from './../mode/modeHandler.ts'; | ||
import { TextEditor } from './../textEditor'; | ||
|
||
export class YankOperator extends Operator { | ||
|
||
constructor(modeHandler: ModeHandler) { | ||
super(modeHandler); | ||
} | ||
|
||
public key(): string { return "y"; } | ||
|
||
/** | ||
* Run this operator on a range. | ||
*/ | ||
public async run(start: Position, end: Position): Promise<void> { | ||
// TODO: use start and end | ||
return TextEditor.copy(new vscode.Range(start, end)).then(() => { | ||
this.modeHandler.currentMode.motion.select(end, end); | ||
this.modeHandler.setNormal(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters