Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 4345ad4

Browse files
committed
fix new file crash in a config with no scripting dirs
1 parent f3a6fcb commit 4345ad4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

UI/MainWindow/MainWindowCommands.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,21 @@ private void Command_New()
9494
return;
9595
}
9696
string newFilePath;
97+
string rootPath;
9798
var newFileNum = 0;
99+
100+
if (Program.Configs[Program.SelectedConfig].SMDirectories.Count > 0)
101+
{
102+
rootPath = Program.Configs[Program.SelectedConfig].SMDirectories[0];
103+
}
104+
else
105+
{
106+
rootPath = Environment.CurrentDirectory;
107+
}
108+
98109
do
99110
{
100-
newFilePath = Path.Combine(Program.Configs[Program.SelectedConfig].SMDirectories[0], $"New Plugin ({++newFileNum}).sp");
111+
newFilePath = Path.Combine(rootPath, $"New Plugin ({++newFileNum}).sp");
101112
} while (File.Exists(newFilePath));
102113

103114
File.Create(newFilePath).Close();

0 commit comments

Comments
 (0)