Skip to content

Commit 9818fb2

Browse files
committed
fix(installer): avoid lsp config rewrites
1 parent df58a36 commit 9818fb2

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/cli/config-io.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,17 @@ describe('config-io', () => {
288288
expect(saved.lsp).toBe(false);
289289
});
290290

291+
test('enableLspByDefault does not write when lsp exists', () => {
292+
const configPath = join(tmpDir, 'opencode', 'opencode.json');
293+
paths.ensureConfigDir();
294+
writeFileSync(configPath, JSON.stringify({ lsp: false }));
295+
296+
const result = enableLspByDefault();
297+
expect(result.success).toBe(true);
298+
299+
expect(existsSync(`${configPath}.bak`)).toBe(false);
300+
});
301+
291302
test('detectCurrentConfig detects installed status', () => {
292303
const configPath = join(tmpDir, 'opencode', 'opencode.json');
293304
const litePath = join(tmpDir, 'opencode', 'oh-my-opencode-slim.json');

src/cli/config-io.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ export function enableLspByDefault(): ConfigMergeResult {
324324

325325
if (config.lsp === undefined) {
326326
config.lsp = true;
327+
writeConfig(configPath, config);
327328
}
328329

329-
writeConfig(configPath, config);
330330
return { success: true, configPath };
331331
} catch (err) {
332332
return {

0 commit comments

Comments
 (0)