File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -150,16 +150,25 @@ private void CrashSave() {
150150 }
151151
152152 public void AutoSave ( ) {
153- if ( Project == null || string . IsNullOrEmpty ( Project . FilePath ) || ! Project . Saved ) {
153+ if ( Project == null ) {
154154 return ;
155155 }
156156 if ( undoQueue . LastOrDefault ( ) == autosavedPoint ) {
157157 Log . Information ( "Autosave skipped." ) ;
158158 return ;
159159 }
160160 try {
161- string dir = Path . GetDirectoryName ( Project . FilePath ) ;
162- string filename = Path . GetFileNameWithoutExtension ( Project . FilePath ) ;
161+ bool untitled = string . IsNullOrEmpty ( Project . FilePath ) ;
162+ if ( untitled ) {
163+ Directory . CreateDirectory ( PathManager . Inst . BackupsPath ) ;
164+ }
165+ string dir = untitled
166+ ? PathManager . Inst . BackupsPath
167+ : Path . GetDirectoryName ( Project . FilePath ) ;
168+ string filename = untitled
169+ ? "Untitled"
170+ : Path . GetFileNameWithoutExtension ( Project . FilePath ) ;
171+
163172 string backup = Path . Join ( dir , filename + "-autosave.ustx" ) ;
164173 Log . Information ( $ "Autosave { backup } .") ;
165174 Format . Ustx . AutoSave ( backup , Project ) ;
You can’t perform that action at this time.
0 commit comments