Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Gabrielsson committed Aug 4, 2024
1 parent cb22982 commit 3008fc3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions nightly/modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ app.module.keyboard = {
if (e.key === value[0]) {
e.preventDefault() // Prevent default tab behavior.

var selection = window.getSelection()
var range = selection.getRangeAt(0)
var selection = window.getSelection(),
range = selection.getRangeAt(0),
spaceNode = document.createTextNode(value[1]) // Create a text node with the value.

// Create a text node with two spaces.
var spaceNode = document.createTextNode(value[1])

// Insert the spaces at the current caret position.
// Insert the value at the current caret position.
range.deleteContents()
range.insertNode(spaceNode)

// Move the caret after the inserted spaces.
// Move the caret after the inserted value.
range.setStartAfter(spaceNode)
range.setEndAfter(spaceNode)
selection.removeAllRanges()
Expand Down

0 comments on commit 3008fc3

Please sign in to comment.