Skip to content

Commit

Permalink
Press tab key to accept spellcheck suggestion (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Jul 31, 2023
1 parent f6d5b69 commit 99965ff
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ extension EditorViewController {
view.needsLayout = true
}

// Press backspace or option to cancel the correction indicator,
// it ensures a smoother word completion experience.
NSEvent.addLocalMonitorForEvents(matching: [.keyDown, .flagsChanged]) { [weak self] event in
// Press backspace or option to cancel the correction indicator,
// it ensures a smoother word completion experience.
if (event.keyCode == 51 || event.keyCode == 58), let self {
NSSpellChecker.shared.declineCorrectionIndicator(for: self.webView)
}

// Press tab key to accept the first spellcheck suggestion
if event.keyCode == 48, let self {
NSSpellChecker.shared.dismissCorrectionIndicator(for: self.webView)
}

return event
}
}
Expand Down

0 comments on commit 99965ff

Please sign in to comment.