From 00dcb4f6e3f23139cc638c3061f97a2e999f27ad Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Mon, 31 Oct 2016 15:06:00 +0200 Subject: [PATCH] Consider click not on selection, when s.rangeCount is 0 --- src/handlers/Clipboard.js | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/handlers/Clipboard.js b/src/handlers/Clipboard.js index bfd3340911..5875ff804b 100644 --- a/src/handlers/Clipboard.js +++ b/src/handlers/Clipboard.js @@ -74,28 +74,28 @@ function pasteHandler(ev, term) { function rightClickHandler(ev, term) { var s = document.getSelection(), sText = prepareTextForClipboard(s.toString()), - r = s.getRangeAt(0); + clickIsOnSelection = false; - var x = ev.clientX, - y = ev.clientY; + if (s.rangeCount) { + var r = s.getRangeAt(0), + cr = r.getClientRects(), + x = ev.clientX, + y = ev.clientY, + i, rect; - var cr = r.getClientRects(), - clickIsOnSelection = false, - i, rect; - - for (i=0; i rect.left) && (x < rect.right) && - (y > rect.top) && (y < rect.bottom) - ); - // If we clicked on selection and selection is not a single space, - // then mark the right click as copy-only. We check for the single - // space selection, as this can happen when clicking on an   - // and there is not much pointing in copying a single space. - // Single space is char - if (clickIsOnSelection && (sText !== ' ')) { - break; + for (i=0; i rect.left) && (x < rect.right) && + (y > rect.top) && (y < rect.bottom) + ); + // If we clicked on selection and selection is not a single space, + // then mark the right click as copy-only. We check for the single + // space selection, as this can happen when clicking on an   + // and there is not much pointing in copying a single space. + if (clickIsOnSelection && (sText !== ' ')) { + break; + } } }