Merge pull request #117062 from NotWearingPants/bugfix/rtl-cursor

Fix cursor position when at the start of RTL syntax tokens
This commit is contained in:
Alexandru Dima 2021-03-09 10:18:47 +01:00 committed by GitHub
commit 63be79e67d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,9 +121,9 @@ export class RangeUtil {
startChildIndex = Math.min(max, Math.max(min, startChildIndex));
endChildIndex = Math.min(max, Math.max(min, endChildIndex));
if (startChildIndex === endChildIndex && startOffset === endOffset && startOffset === 0) {
if (startChildIndex === endChildIndex && startOffset === endOffset && startOffset === 0 && !domNode.children[startChildIndex].firstChild) {
// We must find the position at the beginning of a <span>
// To cover cases of empty <span>s, aboid using a range and use the <span>'s bounding box
// To cover cases of empty <span>s, avoid using a range and use the <span>'s bounding box
const clientRects = domNode.children[startChildIndex].getClientRects();
return this._createHorizontalRangesFromClientRects(clientRects, clientRectDeltaLeft);
}