Buggy code:
public class EditorHelper { private static final Logger logger = Logger . getInstance ( EditorHelper . class . getName ( ) ) ; public static int getVisualLineAtTopOfScreen ( final Editor editor ) { } public static int getCurrentVisualScreenLine ( final Editor editor ) { } public static int getLineLength ( final Editor editor ) { } public static int getLineLength ( final Editor editor , final int lline ) { } public static int getVisualLineLength ( final Editor editor , final int vline ) { } public static int getVisualLineCount ( final Editor editor ) { } public static int getLineCount ( final Editor editor ) { } public static int getFileSize ( final Editor editor ) { } public static int getFileSize ( final Editor editor , final boolean includeEndNewLine ) { } public static int getScreenHeight ( final Editor editor ) { } public static int getScreenWidth ( final Editor editor ) { } public static int getColumnWidth ( final Editor editor ) { } public static int getVisualColumnAtLeftOfScreen ( final Editor editor ) { } public static int visualLineToLogicalLine ( final Editor editor , final int vline ) { } public static int logicalLineToVisualLine ( final Editor editor , final int lline ) { } public static int getLineStartOffset ( final Editor editor , final int lline ) { } public static int getLineEndOffset ( final Editor editor , final int lline , final boolean incEnd ) { } public static int normalizeVisualLine ( final Editor editor , final int vline ) { } public static int normalizeLine ( final Editor editor , final int lline ) { } public static int normalizeVisualColumn ( final Editor editor , final int vline , final int col , final boolean allowEnd ) { } public static int normalizeColumn ( final Editor editor , final int lline , final int col , final boolean allowEnd ) { } public static int normalizeOffset ( final Editor editor , final int lline , final int offset , final boolean allowEnd ) { } public static int normalizeOffset ( final Editor editor , final int offset ) { } public static int normalizeOffset ( final Editor editor , int offset , final boolean allowEnd ) { if ( offset <= 0 ) { return 0 ; } final int textLength = editor . getDocument ( ) . getTextLength ( ) ; if ( offset > textLength ) { offset = textLength ; } <START_BUG> if ( ( ( offset > 0 ) && ( ! allowEnd ) ) && ( ( editor . getDocument ( ) . getCharsSequence ( ) . charAt ( ( textLength - 1 ) ) ) == '\n' ) ) { <END_BUG> offset -- ; } return offset ; } public static int getLeadingCharacterOffset ( final Editor editor , final int lline ) { } public static int getLeadingCharacterOffset ( final Editor editor , final int lline , final int col ) { } public static String getLeadingWhitespace ( final Editor editor , final int lline ) { } @ Nullable public static Editor getEditor ( final FileEditorManager manager , final VirtualFile file ) { } public static int visualPositionToOffset ( final Editor editor , final VisualPosition pos ) { } public static String getText ( final Editor editor , final int start , final int end ) { } public static String getText ( final Editor editor , final TextRange range ) { } public static int getLineStartForOffset ( final Editor editor , final int offset ) { } public static int getLineEndForOffset ( final Editor editor , final int offset ) { } public static int getLineCharCount ( final Editor editor , final int lline ) { } public static String getLineText ( final Editor editor , final int lline ) { } public static CharacterPosition offsetToCharacterPosition ( final Editor editor , final int offset ) { } public static int characterPositionToOffset ( final Editor editor , final CharacterPosition pos ) { } public static CharBuffer getLineBuffer ( final Editor editor , final int lline ) { } public static boolean isLineEmpty ( final Editor editor , final int lline , final boolean allowBlanks ) { } public static String pad ( final Editor editor , int lline , final int to ) { } public static boolean canEdit ( final Project project , final Editor editor ) { } }

Fix:
if ( ( ( offset > 0 ) && ( ! allowEnd ) ) && ( ( editor . getDocument ( ) . getCharsSequence ( ) . charAt ( offset ) ) == '\n' ) ) {