mirror of
https://github.com/talwrii/plugin-repl.git
synced 2026-07-22 11:40:27 +00:00
Add killLine method
This commit is contained in:
parent
233737089f
commit
6605ea90ff
1 changed files with 11 additions and 0 deletions
11
src/main.ts
11
src/main.ts
|
|
@ -289,6 +289,10 @@ export default class ReplPlugin extends Plugin {
|
|||
"kill", kill.bind(null, editor),
|
||||
"(start: Position, end: Position) Delete the region between start and end"
|
||||
)
|
||||
this.addToScopeWithDoc(
|
||||
"killLine", killLine.bind(null, editor),
|
||||
"Delete the current line"
|
||||
)
|
||||
this.addToScopeWithDoc(
|
||||
"lineAtPoint", lineAtPoint.bind(null, editor),
|
||||
"Return the content of the line where the cursor is. Optionally takes a cursor position as an argument"
|
||||
|
|
@ -531,6 +535,13 @@ function kill(editor: Editor, pos1?: EditorPosition, pos2?: EditorPosition) {
|
|||
}
|
||||
|
||||
|
||||
function killLine(editor: Editor) {
|
||||
const cursor = editor.getCursor()
|
||||
const line = editor.getLine(cursor.line)
|
||||
editor.replaceRange("", { ...cursor, ch: 0 }, { ...cursor, ch: line.length })
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue