xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
227 stars 54 forks source link

fix #215 random target is run when you debug #216

Closed raigorx closed 1 year ago

raigorx commented 1 year ago

the problems is in https://github.com/xmake-io/xmake-vscode/blob/8274b8fdcab2e9cfb9549de55a53eaae40233de4/src/launchDebugger.ts#L40-L47

targets.lua return example

[
  "cast\r",
  "decay\r",
  "declaration\r",
  "free_heap_lib\r",
  "function_pointers\r",
  "lambda\r",
  "memmove\r",
  "miscellaneous\r",
  "move_semantics\r",
  "os_stream\r",
  "pointers\r",
  "raw_bytes\r",
  "raw_bytes_lib\r",
  "references\r",
  "return_optimization\r",
  "rvalue\r",
  "smart_pointers\r",
  "templates\r",
  "temporary\r",
  "trivially\r",
  "utils_lib\r",
  "wmemcpy",
]

\r is using a delimiter for each target. getInformations is called in https://github.com/xmake-io/xmake-vscode/blob/8274b8fdcab2e9cfb9549de55a53eaae40233de4/src/launchDebugger.ts#L164-L176 where getInformations gets the targetName from getTargets, that contains \r in the end make it return the wrong target.

I don't like this fix much but seems like the proper way to do, because change the behavior of the targets.lua to no return \r feels error prone.

waruqi commented 1 year ago

I use json to fix it. https://github.com/xmake-io/xmake-vscode/commit/4dd861a8df4d9baf567e8e150bc3c4505be78ea9