private static void handleMoveOutsideQuotes(char c, Editor editor, PsiFile file) {
    JsonEditorOptions options = JsonEditorOptions.getInstance();
    if (c == ':' && options.COLON_MOVE_OUTSIDE_QUOTES || c == ',' && options.COMMA_MOVE_OUTSIDE_QUOTES) {
      int offset = editor.getCaretModel().getOffset();
      CharSequence sequence = editor.getDocument().getCharsSequence();
      int length = sequence.length();
      if (offset >= length || offset < 0) return;
      char charAtOffset = sequence.charAt(offset);
      if (charAtOffset != '"') return;
      if (offset + 1 < length && sequence.charAt(offset + 1) == c) return;
      final PsiElement element = file.findElementAt(offset);
      if (element == null) return;
      if (!validatePositionToMoveOutOfQuotes(c, element)) return;
      PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
      editor.getDocument().deleteString(offset - 1, offset);
      editor.getDocument().insertString(offset, String.valueOf(c));
      CharSequence newSequence = editor.getDocument().getCharsSequence();
      int nextOffset = offset + 1;
      if (c == ':' && options.AUTO_WHITESPACE_AFTER_COLON) {
        char nextChar = nextOffset >= newSequence.length() ? 'a' : newSequence.charAt(nextOffset);
        if (!Character.isWhitespace(nextChar) || nextChar == '\n') {
          editor.getDocument().insertString(nextOffset, " ");
          nextOffset++;
        }
      }
      editor.getCaretModel().moveToOffset(nextOffset);
    }
  }
private static void handleMoveOutsideQuotes(char c, Editor editor, PsiFile file)