diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-22 14:20:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-22 18:05:46 +0200 |
commit | 2d1a8f83ce4c74b2ede1e93e8e1d309a61b8af23 (patch) | |
tree | 0543143257b27657a667718f579a3fb4808c8e63 /vcl/unx/gtk3/gtk3gtkinst.cxx | |
parent | f09cd9d20a01e8bf8e55d9ffc17ad3b3d7b20116 (diff) |
fix welded editengine delete-surrounding
Change-Id: I71c2f8e2483c2ef8d7f5cfcfcd7849f64792022f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104659
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/gtk3/gtk3gtkinst.cxx')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 13f97ceb7df9..fd4c339f5337 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -13851,19 +13851,40 @@ public: if (nOffset > 0) { - while (nCursorIndex < sSurroundingText.getLength()) + while (nOffset && nCursorIndex < sSurroundingText.getLength()) + { sSurroundingText.iterateCodePoints(&nCursorIndex, 1); + --nOffset; + } } else if (nOffset < 0) { - while (nCursorIndex > 0) + while (nOffset && nCursorIndex > 0) + { sSurroundingText.iterateCodePoints(&nCursorIndex, -1); + ++nOffset; + } + } + + if (nOffset) + { + SAL_WARN("vcl.gtk", "IM delete-surrounding, unable to move to offset: " << nOffset); + return false; } sal_Int32 nCursorEndIndex(nCursorIndex); sal_Int32 nCount(0); while (nCount < nChars && nCursorEndIndex < sSurroundingText.getLength()) + { + sSurroundingText.iterateCodePoints(&nCursorEndIndex, 1); ++nCount; + } + + if (nCount != nChars) + { + SAL_WARN("vcl.gtk", "IM delete-surrounding, unable to select: " << nChars << " characters"); + return false; + } bRet = pThis->m_pArea->im_context_delete_surrounding(Selection(nCursorIndex, nCursorEndIndex)); } |