Buggy code:
public void insertBeforeCursor ( Editor editor , DataContext context ) { } public void insertBeforeFirstNonBlank ( Editor editor , DataContext context ) { } public void insertLineStart ( Editor editor , DataContext context ) { } public void insertAfterCursor ( Editor editor , DataContext context ) { } public void insertAfterLineEnd ( Editor editor , DataContext context ) { } public void insertNewLineAbove ( final Editor editor , final DataContext context ) { } public void insertNewLineBelow ( final Editor editor , final DataContext context ) { } public void insertAtPreviousInsert ( Editor editor , DataContext context ) { } public void insertPreviousInsert ( Editor editor , DataContext context , boolean exit ) { } public void insertHelp ( Editor editor , DataContext context ) { } public boolean insertRegister ( Editor editor , DataContext context , char key ) { } public boolean insertCharacterAroundCursor ( Editor editor , DataContext context , int dir ) { } public boolean insertDeleteInsertedText ( Editor editor , DataContext context ) { } public boolean insertDeletePreviousWord ( Editor editor , DataContext context ) { } private void initInsert ( Editor editor , DataContext context , int mode ) { } private void repeatInsert ( Editor editor , DataContext context , int count , boolean started ) { } private void repeatInsertText ( Editor editor , DataContext context , int count ) { } public void processEscape ( Editor editor , DataContext context ) { } public void processEnter ( Editor editor , DataContext context ) { } public void processInsert ( Editor editor , DataContext context ) { } public void processSingleCommand ( Editor editor , DataContext context ) { } public boolean processKey ( final Editor editor , final DataContext context , final KeyStroke key ) { } public boolean processCommand ( Editor editor , DataContext context , Command cmd ) { } private void clearStrokes ( Editor editor ) { } public boolean deleteCharacter ( Editor editor , DataContext context , int count ) { } public boolean deleteLine ( Editor editor , DataContext context , int count ) { } public boolean deleteEndOfLine ( Editor editor , DataContext context , int count ) { } public boolean deleteJoinLines ( Editor editor , DataContext context , int count , boolean spaces ) { } public boolean deleteJoinRange ( Editor editor , DataContext context , TextRange range , boolean spaces ) { } private boolean deleteJoinNLines ( Editor editor , DataContext context , int startLine , int count , boolean spaces ) { } public boolean deleteMotion ( Editor editor , DataContext context , int count , int rawCount , Argument argument , boolean isChange ) { } public boolean deleteRange ( Editor editor , DataContext context , TextRange range , int type , boolean isChange ) { } public boolean changeReplace ( Editor editor , DataContext context ) { } public boolean changeCharacter ( Editor editor , DataContext context , int count , char ch ) { } public boolean changeCharacterRange ( Editor editor , DataContext context , TextRange range , char ch ) { } public boolean changeCharacters ( Editor editor , DataContext context , int count ) { } public boolean changeLine ( Editor editor , DataContext context , int count ) { } public boolean changeEndOfLine ( Editor editor , DataContext context , int count ) { } public boolean changeMotion ( Editor editor , DataContext context , int count , int rawCount , Argument argument ) { } public boolean blockInsert ( Editor editor , DataContext context , TextRange range , boolean append ) { } public boolean changeRange ( Editor editor , DataContext context , TextRange range , int type ) { } public boolean changeCaseToggleCharacter ( Editor editor , DataContext context , int count ) { int offset = CommandGroups . getInstance ( ) . getMotion ( ) . moveCaretHorizontal ( editor , count , true ) ; if ( offset == ( - 1 ) ) { return false ; } else { changeCase ( editor , context , editor . getCaretModel ( ) . getOffset ( ) , offset , CASE_TOGGLE ) ; <START_BUG> offset = EditorHelper . normalizeOffset ( editor , ( offset + 1 ) , false ) ; <END_BUG> MotionGroup . moveCaret ( editor , context , offset ) ; return true ; } } public boolean changeCaseMotion ( Editor editor , DataContext context , int count , int rawCount , char type , Argument argument ) { } public boolean changeCaseRange ( Editor editor , DataContext context , TextRange range , char type ) { } private void changeCase ( Editor editor , DataContext context , int start , int end , char type ) { } public void autoIndentLines ( Editor editor , DataContext context , int lines ) { } public void indentLines ( Editor editor , DataContext context , int lines , int dir ) { } public void indentMotion ( Editor editor , DataContext context , int count , int rawCount , Argument argument , int dir ) { } public void indentRange ( Editor editor , DataContext context , TextRange range , int count , int dir ) { } public void insertText ( Editor editor , DataContext context , int start , String str ) { } private boolean deleteText ( final Editor editor , final DataContext context , final TextRange range , final int type ) { } private void replaceText ( Editor editor , DataContext context , int start , int end , String str ) { } public static void resetCursor ( Editor editor , boolean insert ) { } private static void resetCursor ( VirtualFile virtualFile , Project proj , boolean insert ) { } public boolean changeNumber ( final Editor editor , final DataContext context , final int count ) { } private ArrayList strokes = new ArrayList ( ) ; private ArrayList lastStrokes ; private int insertStart ; private Command lastInsert ; private boolean inInsert ;

Fix:
offset = EditorHelper . normalizeOffset ( editor , offset , true ) ;