Desktop: Fixes: #4317: Spell checker inserts correction at wrong location (#4318)

pull/4306/head
Caleb John 2021-01-07 10:01:44 -07:00 committed by GitHub
parent 826dda5a75
commit 98cbb237b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import markdownUtils from '@joplin/lib/markdownUtils'; import markdownUtils from '@joplin/lib/markdownUtils';
import Setting from '@joplin/lib/models/Setting';
// Helper functions that use the cursor // Helper functions that use the cursor
export default function useCursorUtils(CodeMirror: any) { export default function useCursorUtils(CodeMirror: any) {
@ -120,8 +121,12 @@ export default function useCursorUtils(CodeMirror: any) {
return -1; return -1;
}; };
// CodeMirror coordsChar doesn't properly scale values when zoomed
// we need to manually apply the zoom
const zoomFactor = Setting.value('windowContentZoomFactor') / 100;
const selectionText = params.selectionText; const selectionText = params.selectionText;
const coords = this.coordsChar({ left: params.x, top: params.y }); const coords = this.coordsChar({ left: params.x / zoomFactor, top: params.y / zoomFactor });
const { anchor, head } = this.findWordAt(coords); const { anchor, head } = this.findWordAt(coords);
const selectedWord = this.getRange(anchor, head); const selectedWord = this.getRange(anchor, head);