Skip to content

Commit

Permalink
Add delete line command
Browse files Browse the repository at this point in the history
  • Loading branch information
FIameCaster committed Jan 9, 2024
1 parent 206dd3d commit 617da31
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions package/src/extensions/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,20 @@ export const defaultCommands = (
scroll()
}
}
} else if (code == 8 + mod && keyCode == 75) {
const value = editor.value,
[start, end, dir] = getSelection(),
[lines, start1, end1] = getLines(value, start, end),
column = dir == "forward" ? end - end1 + lines.pop()!.length : start - start1,
newLineLen = getLines(value, end1 + 1)[0][0].length
insertText(
editor,
"",
start1 - <any>!!start1,
end1 + <any>!start1,
start1 + Math.min(column, newLineLen),
)
scroll()
}
})
;(["copy", "cut", "paste"] as const).forEach(type =>
Expand Down

0 comments on commit 617da31

Please sign in to comment.