microsoft / vscode-makefile-tools

MAKE integration in Visual Studio Code
Other
194 stars 58 forks source link

"Build Target" list does not support single character targets #441

Closed nick-hebi closed 1 year ago

nick-hebi commented 1 year ago

This is a bug that is related to the regex on Line 55 of parser.ts. The extension fails to recognize build targets in the Makefile that are a single character long (such as "A:").

I believe that this regex should be changed from "^(?!\\n?[#\\.])(?<!^\\n?# Not a target:\\s*)\\s*(\\S+[^:]):\\s+" to "^(?!\\n?[#\\.])(?<!^\\n?# Not a target:\\s*)\\s*(\\S*[^:]):\\s+".

This regex is checking for a group of characters that ends in a single ':' character. The usage of (\\S+[^:]) fails on single character build target cases such as "A:" because the + consumes the first character and causes the [^:] condition to fail. Changing the + to a * remedies this issue while preserving the intended behavior of this line.

nick-hebi commented 1 year ago

PR Opened https://github.com/microsoft/vscode-makefile-tools/pull/442

andreeis commented 1 year ago

@nick-hebi , thank you for finding this issue and for submitting a fix. Being so small we can easily include in the 0.7 release.