PreviousNextTracker indexSee it online !

(230/244) 4011 - The Cut Lines macro gives exception if the cursor is beyond text area

If the cursor is on a line beyond the last line of text, the Cut Liners macro throws an exception. The fix for the exception is to change the Cut Lines macro to read:

cutLines(){
if (buffer.getLength() == 0)
return;
selections = textArea.getSelectedLines();

if(selections.length == 0){
selections = new int [] {textArea.getCaretLine()};
}
start = textArea.getLineStartOffset(selections[0]);
stop = textArea.getLineEndOffset(selections[selections.length-1]);
blen = textArea.getBufferLength();
if (start < blen && stop <= blen)
{
textArea.setSelection(new Selection.Range(start,stop));
Registers.cut(textArea,'$');
}
}

The jedit version is 5.3.1 using Java 1.8.0_91.

Submitted eldienerlee - 2016-08-15 18:19:44.457000 Assigned
Priority 5 Labels
Status open Group normal bug
Resolution None

Comments

2017-10-09 03:18:11.612000
tsourick

Here is my solution as a patch which also works for the last line

https://sourceforge.net/p/jedit/patches/600/