using the spell checker to replace a misspelled word crashes electronjs.
williamstein opened this issue · 2 comments
On MacOS, at least for my relatively simple electronjs application, any time I try to replace an incorrectly spelled word, the entire application crashes. I'm using the latest version of Electron.js as of this writing.
I made a simple one-line change in the index.js file and that completely fixed the problem, i.e., replace insertText by replaceMisspelling. Also the change of course makes a lot of sense:
function word(suggestion) {
return {
id: 'dictionarySuggestions',
label: suggestion,
visible: Boolean(props.isEditable && hasText && props.misspelledWord),
click(menuItem) {
const target = webContents(win);
//target.insertText(menuItem.label);
target.replaceMisspelling(menuItem.label);
...
Using replaceMisspelling seems reasonable given it is what we're doing and is now part of the documented electron.js API: https://www.electronjs.org/docs/api/web-contents#contentsreplacemisspellingtext
I've made a PR: #138
I've also confirmed that this bug happens (for my application) on MS Windows, and that this bugfix also works there.