Skip to content

Commit

Permalink
remove handling of jumping to beginning of line
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Jul 6, 2020
1 parent 77866d3 commit 6281405
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions codejar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
prev = toString()
handleNewLine(event)
handleTabCharacters(event)
handleJumpToBeginningOfLine(event)
handleSelfClosingCharacters(event)
handleUndoRedo(event)
if (shouldRecord(event) && !recording) {
Expand Down Expand Up @@ -283,29 +282,6 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void
}
}

function handleJumpToBeginningOfLine(event: KeyboardEvent) {
if (event.key === "ArrowLeft" && event.metaKey) {
preventDefault(event)
const before = beforeCursor()
let [padding, start, end] = findPadding(before)
if (before.endsWith(padding)) {
if (event.shiftKey) {
const pos = save()
restore({start, end: pos.end}) // Select from line start.
} else {
restore({start, end: start}) // Jump to line start.
}
} else {
if (event.shiftKey) {
const pos = save()
restore({start: end, end: pos.end}) // Select from beginning of text.
} else {
restore({start: end, end}) // Jump to beginning of text.
}
}
}
}

function handleUndoRedo(event: KeyboardEvent) {
if (isUndo(event)) {
preventDefault(event)
Expand Down

0 comments on commit 6281405

Please sign in to comment.