X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTEditorWidget.java;fp=src%2Fjexer%2FTEditorWidget.java;h=6d24a196af8881cd75c70455cdbae8b94dd2b618;hb=9240f032a51de25bdc90bdebec99bb63896b24d0;hp=9236da2a89a57afd06cd62e3463c800bcd573df2;hpb=3d3e09e625a95ca9b005166f4a9924c9aadfc65c;p=fanfix.git diff --git a/src/jexer/TEditorWidget.java b/src/jexer/TEditorWidget.java index 9236da2..6d24a19 100644 --- a/src/jexer/TEditorWidget.java +++ b/src/jexer/TEditorWidget.java @@ -164,8 +164,15 @@ public class TEditorWidget extends TWidget implements EditMenuUser { if (mouse.isMouse1()) { // Selection. + int newLine = topLine + mouse.getY(); + int newX = leftColumn + mouse.getX(); + inSelection = true; - selectionLine0 = topLine + mouse.getY(); + if (newLine > document.getLineCount() - 1) { + selectionLine0 = document.getLineCount() - 1; + } else { + selectionLine0 = topLine + mouse.getY(); + } selectionColumn0 = leftColumn + mouse.getX(); selectionColumn0 = Math.max(0, Math.min(selectionColumn0, document.getLine(selectionLine0).getDisplayLength() - 1)); @@ -173,8 +180,6 @@ public class TEditorWidget extends TWidget implements EditMenuUser { selectionLine1 = selectionLine0; // Set the row and column - int newLine = topLine + mouse.getY(); - int newX = leftColumn + mouse.getX(); if (newLine > document.getLineCount() - 1) { // Go to the end document.setLineNumber(document.getLineCount() - 1);