@@ -27,6 +27,8 @@ export class CodeServerRouteWrapper {
27
27
private $root : express . Handler = async ( req , res , next ) => {
28
28
const isAuthenticated = await authenticated ( req )
29
29
const NO_FOLDER_OR_WORKSPACE_QUERY = ! req . query . folder && ! req . query . workspace
30
+ // Ew means the workspace was closed so clear the last folder/workspace.
31
+ const WORKSPACE_WAS_CLOSED = req . query . ew
30
32
31
33
if ( ! isAuthenticated ) {
32
34
const to = self ( req )
@@ -35,21 +37,19 @@ export class CodeServerRouteWrapper {
35
37
} )
36
38
}
37
39
38
- if ( NO_FOLDER_OR_WORKSPACE_QUERY ) {
40
+ if ( NO_FOLDER_OR_WORKSPACE_QUERY && ! WORKSPACE_WAS_CLOSED ) {
39
41
const settings = await req . settings . read ( )
40
42
const lastOpened = settings . query || { }
41
- // Ew means the workspace was closed so clear the last folder/workspace.
42
- const HAS_EW_QUERY = req . query . ew
43
43
// This flag disables the last opened behavior
44
44
const IGNORE_LAST_OPENED = req . args [ "ignore-last-opened" ]
45
- const HAS_LAST_OPENED_FOLDER_OR_WORKSPACE = lastOpened . folder || lastOpened . workspace
45
+ const HAS_LAST_OPENED_FOLDER_OR_WORKSPACE = ( ! WORKSPACE_WAS_CLOSED && lastOpened . folder ) || lastOpened . workspace
46
46
const HAS_FOLDER_OR_WORKSPACE_FROM_CLI = req . args . _ . length > 0
47
47
const to = self ( req )
48
48
49
49
let folder = undefined
50
50
let workspace = undefined
51
51
52
- if ( HAS_EW_QUERY ) {
52
+ if ( WORKSPACE_WAS_CLOSED ) {
53
53
delete lastOpened . folder
54
54
delete lastOpened . workspace
55
55
}
@@ -69,10 +69,13 @@ export class CodeServerRouteWrapper {
69
69
folder = lastEntry
70
70
}
71
71
}
72
- return redirect ( req , res , to , {
73
- folder,
74
- workspace,
75
- } )
72
+
73
+ if ( folder || workspace ) {
74
+ return redirect ( req , res , to , {
75
+ folder,
76
+ workspace,
77
+ } )
78
+ }
76
79
}
77
80
78
81
// Store the query parameters so we can use them on the next load. This
0 commit comments