Skip to content

Commit 535ccf8

Browse files
fix: fix restart
1 parent 62aac47 commit 535ccf8

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/extension/lsp.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ export async function activateLsp(context: ExtensionContext) {
8181
return
8282
}
8383

84+
setupClient()
85+
86+
// Automatically start the client only if we can find a config file
87+
if (
88+
(await fileExists('sgconfig.yml')) ||
89+
(await fileExists('sgconfig.yaml'))
90+
) {
91+
// Start the client. This will also launch the server
92+
client.start()
93+
} else {
94+
client.outputChannel.appendLine(
95+
'no project file sgconfig.yml found in root. Skip starting LSP.',
96+
)
97+
}
98+
}
99+
100+
function setupClient() {
84101
// instantiate and set input which updates the view
85102
// If the extension is launched in debug mode then the debug server options are used
86103
// Otherwise the run options are used
@@ -104,20 +121,12 @@ export async function activateLsp(context: ExtensionContext) {
104121
serverOptions,
105122
clientOptions,
106123
)
107-
108-
// Automatically start the client only if we can find a config file
109-
if (
110-
(await fileExists('sgconfig.yml')) ||
111-
(await fileExists('sgconfig.yaml'))
112-
) {
113-
// Start the client. This will also launch the server
114-
client.start()
115-
}
116124
}
117125

118126
async function restart(): Promise<void> {
119127
await deactivate()
120128
if (client) {
129+
setupClient()
121130
await client.start()
122131
}
123132
}

0 commit comments

Comments
 (0)