Reproduction recipe of the problem: 1. Open an arbitrary buffer and select some texts. 2. Create a new file without jEdit. The path of this file must not be in jEdit's history. 3. Open the file with jEdit. After the above steps, the selection in newly opened buffer is not cleared (remains at same offsets in step 1). If the new file is longer than offsets of the selection, the selection appears in the new buffer. Otherwise, accessing to the selected offsets results in ArrayIndexOutOfBoundsException. I found this problem while testing the recent changes to ColumnRuler plugin. In this case, the exception is thrown by paint() method of ColumnRuler, and jEdit gives up the remaining paint operation. This small patch will fix the problem.