Buggy code:
public class Main extends Application { public static final String BASELAYERNAME = "Base" ; public static final String VERSION = "ErgodoxLayoutGenerator<seq2seq4repair_space>V1.0BETA1" ; private static final File configFile = new File ( ( ( System . getProperty ( "user.home" ) ) + "//.ergodoxgenerator.conf" ) ) ; public static Properties applicationSettings ; public final int pixelWidth = 40 ; public final int pixelHeight = 25 ; public final int pixelOffsetX = 5 ; public final int pixelOffsetY = 5 ; public final int offsetX = 25 ; public final int offsetY = 75 ; private final String qmksourcedir = "qmksourcedir" ; public int rightHalfOffset = 400 ; private double scaleX = 1.0 ; private double scaleY = 1.0 ; private GuiKey selectedGuiKey = null ; private Button setSourceDir ; private Label sourceDirLabel ; private Button createKeymap ; private Button openBtn ; private Button saveBtn ; private Button reopenBtn ; private int basicCalculationWith ; private int basicCalculationHeight ; private double currentWindowHeight ; private double currentWindowWidth ; private ComboBox < String > layerCombo ; private Button createLayer ; private Button renameLayer ; private Button deleteLayer ; private ErgodoxLayoutLayer currentLayer ; private Pane canvas ; private File qmkSourceDir ; private Label legendStandardKey ; private Label legendLayerSwitch ; private Label legendTempSwitch ; private Label legendMacroCall ; private Label legendModifierKey ; private Label legendCombination ; private Label legendMomLayer ; private Label legendHoldKey ; private Label keyDescription ; private Button saveImgBtn ; private String currentKeymap ; private Label ledDesc ; private Label led1 ; private Label led2 ; private Label led3 ; private ErgodoxLayout ergodoxLayout ; private String lastOpenedFile = "last_opened_file" ; private List < GuiKey > guiKeys = new ArrayList < > ( ) ; private Button compileBtn ; public static void main ( String [ ] args ) { } public static Map < String , String > getPrefixDescriptionMap ( ) { } public static List < String > getKeyCodesList ( ) { } public static void saveConfig ( ) { } public static String getKeyDisplayText ( String kval , Map < String , Macro > macros ) { } private static String getKeyDisplayName ( String ret ) { } public void start ( Stage primaryStage ) throws Exception { } private void doCompile ( ) { } private int execCommand ( final Writer wr , String cmd ) throws Exception { } private void newLayout ( ) { } private void updateWindowHeight ( double newValue ) { } private void updateWindowWidth ( double newValue ) { } private String askForLayerName ( String o ) { } private void doAssignMacro ( Key k ) { } private void doAssingLayerToggle ( Key k ) { } private void doAssignLT ( Key k ) { } private void doAssignKey ( Key k ) { } public void saveKeymap ( ) { try { FileChooser fc = new FileChooser ( ) ; if ( ( ( qmkSourceDir ) == null ) || ( ! ( qmkSourceDir . exists ( ) ) ) ) { Alert a = new Alert ( Alert . AlertType . ERROR , "Cannot<seq2seq4repair_space>save<seq2seq4repair_space>if<seq2seq4repair_space>QMK-Sourcedir<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>set!" , ButtonType . CLOSE ) ; a . showAndWait ( ) ; return ; } File startFile = new File ( ( ( ( ( qmkSourceDir . getPath ( ) ) + "//keyboard//ergodox_ez//keymaps//" ) + ( currentKeymap ) ) + "//keymap.c" ) ) ; <START_BUG> if ( ! ( startFile . exists ( ) ) ) { <END_BUG> startFile = new File ( currentKeymap ) ; } if ( ! ( startFile . exists ( ) ) ) { startFile = new File ( ( ( qmkSourceDir . getPath ( ) ) + "//keyboard//ergodox_ez//keymaps" ) ) ; } if ( startFile . isDirectory ( ) ) { fc . setInitialDirectory ( startFile ) ; } else { fc . setInitialDirectory ( startFile . getParentFile ( ) ) ; } fc . setInitialFileName ( "keymap.c" ) ; File selected = fc . showSaveDialog ( null ) ; if ( selected == null ) return ; if ( ! ( selected . getAbsolutePath ( ) . startsWith ( qmkSourceDir . getAbsolutePath ( ) ) ) ) { Alert a = new Alert ( Alert . AlertType . CONFIRMATION , "" , ButtonType . YES , ButtonType . NO ) ; a . setTitle ( "Warning" ) ; a . setContentText ( "Directory<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>within<seq2seq4repair_space>the<seq2seq4repair_space>QMK-Source<seq2seq4repair_space>-<seq2seq4repair_space>you<seq2seq4repair_space>won't<seq2seq4repair_space>be<seq2seq4repair_space>able<seq2seq4repair_space>to<seq2seq4repair_space>compile<seq2seq4repair_space>it.<seq2seq4repair_space>Proceed?" ) ; a . setHeaderText ( "Directory<seq2seq4repair_space>location" ) ; Optional < ButtonType > result = a . showAndWait ( ) ; if ( ( result . get ( ) ) != ( ButtonType . YES ) ) { saveKeymap ( ) ; return ; } } if ( ! ( selected . getName ( ) . equals ( "keymap.c" ) ) ) { Alert a = new Alert ( Alert . AlertType . WARNING , "" , ButtonType . YES , ButtonType . NO ) ; a . setTitle ( "Warning" ) ; a . setContentText ( "File<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>named<seq2seq4repair_space>keymap.c<seq2seq4repair_space>-<seq2seq4repair_space>you<seq2seq4repair_space>won't<seq2seq4repair_space>be<seq2seq4repair_space>able<seq2seq4repair_space>to<seq2seq4repair_space>compile.<seq2seq4repair_space>Proceed?" ) ; a . setHeaderText ( "Filename<seq2seq4repair_space>not<seq2seq4repair_space>ok" ) ; Optional < ButtonType > result = a . showAndWait ( ) ; if ( ( result . get ( ) ) != ( ButtonType . YES ) ) { saveKeymap ( ) ; return ; } } KeymapWriter writer = new KeymapWriter ( ) ; writer . writeKeymapFile ( ergodoxLayout , new File ( selected . getAbsolutePath ( ) ) ) ; Main . applicationSettings . setProperty ( lastOpenedFile , selected . getAbsolutePath ( ) ) ; Main . saveConfig ( ) ; } catch ( Exception e ) { showErrorMessage ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>write<seq2seq4repair_space>keymap" , e ) ; } } private void showLongContent ( String msg , String longContent ) { } private void showErrorMessage ( String msg , Exception ex ) { } private void saveAsPng ( ) { } private void readConfig ( ) { } private void layoutLabel ( Label l , Color c ) { } private void openKeymap ( Stage primaryStage ) { } private void readKeymapFile ( Stage primaryStage , File selected ) throws Exception { }

Fix:
if ( ( ! ( startFile . exists ( ) ) ) && ( ( currentKeymap ) != null ) ) {