Skip to content

Commit ad09525

Browse files
authored
Merge pull request #926 from codeflash-ai/lsp/move-config-suggestion-default-values-to-the-client
[LSP][FIX] prefill the existing config values from the client
2 parents 848faa5 + 283524d commit ad09525

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

codeflash/lsp/beta.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -235,37 +235,11 @@ def get_config_suggestions(_params: any) -> dict[str, any]:
235235
tests_root_suggestions.append(".")
236236
default_tests_root = tests_root_suggestions[0] if tests_root_suggestions else "."
237237

238-
try:
239-
configured_module_root = (
240-
Path(server.args.module_root).relative_to(Path.cwd()) if server.args.module_root else None
241-
)
242-
except: # noqa : E722
243-
configured_module_root = None
244-
try:
245-
configured_tests_root = Path(server.args.tests_root).relative_to(Path.cwd()) if server.args.tests_root else None
246-
except: # noqa : E722
247-
configured_tests_root = None
248-
try:
249-
configured_test_framework = server.args.test_framework if server.args.test_framework else None
250-
except: # noqa : E722
251-
configured_test_framework = None
252-
configured_formatter = ""
253-
try:
254-
if isinstance(server.args.formatter_cmds, list):
255-
configured_formatter = " && ".join([cmd.strip() for cmd in server.args.formatter_cmds])
256-
elif isinstance(server.args.formatter_cmds, str):
257-
configured_formatter = server.args.formatter_cmds.strip()
258-
except: # noqa : E722
259-
configured_formatter = "disabled"
260-
261238
return {
262-
"module_root": {"choices": module_root_suggestions, "default": configured_module_root or default_module_root},
263-
"tests_root": {"choices": tests_root_suggestions, "default": configured_tests_root or default_tests_root},
264-
"test_framework": {
265-
"choices": test_framework_suggestions,
266-
"default": configured_test_framework or default_test_framework,
267-
},
268-
"formatter_cmds": {"choices": formatter_suggestions, "default": configured_formatter or default_formatter},
239+
"module_root": {"choices": module_root_suggestions, "default": default_module_root},
240+
"tests_root": {"choices": tests_root_suggestions, "default": default_tests_root},
241+
"test_framework": {"choices": test_framework_suggestions, "default": default_test_framework},
242+
"formatter_cmds": {"choices": formatter_suggestions, "default": default_formatter},
269243
}
270244

271245

@@ -319,7 +293,13 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]:
319293
}
320294

321295
args = process_args()
322-
return {"status": "success", "moduleRoot": args.module_root, "pyprojectPath": pyproject_toml_path, "root": root}
296+
return {
297+
"status": "success",
298+
"moduleRoot": args.module_root,
299+
"pyprojectPath": pyproject_toml_path,
300+
"root": root,
301+
"existingConfig": config,
302+
}
323303

324304

325305
def _initialize_optimizer_if_api_key_is_valid(api_key: Optional[str] = None) -> dict[str, str]:

0 commit comments

Comments
 (0)