Program: 80721
Project: 80721
Buggy source:
/** 
 * Moves tab in the specified direction. This is way more complicated than it should have been. The main reasons are: - closing/opening or opening/closing tab doesn't guarantee that focus will be in the moved tab => need to track target window to move focus into it - EditorWindow object changes its identity after split/unsplit (i.e. points to another visual window) => need to predict target window position and look up window by expected position
 */
public void moveTab(Directions.Direction direction){
  LayoutElement layout=calculateAndSetPositions(ide.snapshotWindowLayout());
  if (layout == LayoutElement.none)   return;
  Window window=currentWindowIn(layout);
  Window targetWindow=direction.findTargetWindow(window,layout);
  Position newPosition;
  boolean isAtEdge=(targetWindow == null);
  if (isAtEdge) {
    if (window.hasOneTab || !direction.canExpand())     return;
    LayoutElement newLayout=insertSplit(direction.splitOrientation(),window,layout);
    calculateAndSetPositions(newLayout);
    LayoutElement sibling=findSiblingOf(window,newLayout);
    if (sibling == null)     return;
    newPosition=sibling.position;
    ide.createSplitter(direction.splitOrientation());
    ide.closeCurrentFileIn(window);
  }
 else {
    boolean willBeUnsplit=window.hasOneTab;
    if (willBeUnsplit) {
      LayoutElement unsplitLayout=removeFrom(layout,window);
      calculateAndSetPositions(unsplitLayout);
    }
    newPosition=targetWindow.position;
    ide.openCurrentFileIn(targetWindow);
    ide.closeCurrentFileIn(window);
  }
  LayoutElement newWindowLayout=calculateAndSetPositions(ide.snapshotWindowLayout());
  targetWindow=findWindowBy(newPosition,newWindowLayout);
  if (targetWindow == null) {
    logger.warn("String_Node_Str" + newPosition);
  }
 else {
    ide.setFocusOn(targetWindow);
  }
}

Fixed version (ground truth):
/** 
 * Moves tab in the specified direction. This is way more complicated than it should have been. The main reasons are: - closing/opening or opening/closing tab doesn't guarantee that focus will be in the moved tab => need to track target window to move focus into it - EditorWindow object changes its identity after split/unsplit (i.e. points to another visual window) => need to predict target window position and look up window by expected position
 */
public void moveTab(Directions.Direction direction){
  LayoutElement layout=calculateAndSetPositions(ide.snapshotWindowLayout());
  if (layout == LayoutElement.none)   return;
  Window window=currentWindowIn(layout);
  if (window == null)   return;
  Window targetWindow=direction.findTargetWindow(window,layout);
  Position newPosition;
  boolean isAtEdge=(targetWindow == null);
  if (isAtEdge) {
    if (window.hasOneTab || !direction.canExpand())     return;
    LayoutElement newLayout=insertSplit(direction.splitOrientation(),window,layout);
    calculateAndSetPositions(newLayout);
    LayoutElement sibling=findSiblingOf(window,newLayout);
    if (sibling == null)     return;
    newPosition=sibling.position;
    ide.createSplitter(direction.splitOrientation());
    ide.closeCurrentFileIn(window);
  }
 else {
    boolean willBeUnsplit=window.hasOneTab;
    if (willBeUnsplit) {
      LayoutElement unsplitLayout=removeFrom(layout,window);
      calculateAndSetPositions(unsplitLayout);
    }
    newPosition=targetWindow.position;
    ide.openCurrentFileIn(targetWindow);
    ide.closeCurrentFileIn(window);
  }
  LayoutElement newWindowLayout=calculateAndSetPositions(ide.snapshotWindowLayout());
  targetWindow=findWindowBy(newPosition,newWindowLayout);
  if (targetWindow == null) {
    logger.warn("String_Node_Str" + newPosition);
  }
 else {
    ide.setFocusOn(targetWindow);
  }
}