Skip to content

Commit 74fd1ff

Browse files
committed
Use top level folder name instead of finding bin/tool/etc. anywhere in the path
1 parent 0925822 commit 74fd1ff

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎src/extension/providers/debug_config_provider.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,19 @@ export class DebugConfigProvider implements DebugConfigurationProvider {
312312
const isIntegrationTest = debugConfig.program && isInsideFolderNamed(debugConfig.program, "integration_test");
313313

314314
let debugType = DebuggerType.Dart;
315-
if (debugConfig.cwd
316-
// TODO: This isInsideFolderNamed often fails when we found a better project root above.
317-
&& !isInsideFolderNamed(debugConfig.program, "bin")
318-
&& !isInsideFolderNamed(debugConfig.program, "tool")
319-
&& !isInsideFolderNamed(debugConfig.program, ".dart_tool")) {
320-
// Check if we're a Flutter or Web project.
321-
if (isFlutterProjectFolder(debugConfig.cwd) || this.wsContext.config.forceFlutterDebug) {
322-
debugType = DebuggerType.Flutter;
323-
} else if (isInsideFolderNamed(debugConfig.program, "web") && !isInsideFolderNamed(debugConfig.program, "test"))
324-
debugType = DebuggerType.Web;
325-
326-
else
327-
logger.info(`Project (${debugConfig.program}) not recognised as Flutter or Web, will use Dart debugger`);
315+
if (debugConfig.cwd && debugConfig.program && isWithinPath(debugConfig.program, debugConfig.cwd)) {
316+
const relativePath = path.relative(debugConfig.cwd, debugConfig.program);
317+
const firstPathSegment = relativePath.split(path.sep)[0];
318+
if (firstPathSegment !== "bin" && firstPathSegment !== "tool" && firstPathSegment !== ".dart_tool") {
319+
// Check if we're a Flutter or Web project.
320+
if (isFlutterProjectFolder(debugConfig.cwd) || this.wsContext.config.forceFlutterDebug) {
321+
debugType = DebuggerType.Flutter;
322+
} else if (firstPathSegment === "web")
323+
debugType = DebuggerType.Web;
324+
else
325+
logger.info(`Program (${debugConfig.program}) not recognised as Flutter or Web, will use Dart debugger`);
326+
}
327+
logger.info(`Program is 'bin', 'tool' or '.dart_tool' so will use Dart debugger`);
328328
}
329329
logger.info(`Detected launch project as ${DebuggerType[debugType]}`);
330330

‎src/test/dart_debug/debugger_type.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe("dart debugger", () => {
2121
"lib/temp1_test.dart": DebuggerType.Dart,
2222
"lib/temp2_test.dart*": DebuggerType.DartTest, // Special case for allowTestsOutsideTestFolder
2323
"test/temp_test.dart": DebuggerType.DartTest,
24+
"test/tool/temp_tool_test.dart": DebuggerType.DartTest,
2425
"tool/temp_tool.dart": DebuggerType.Dart,
2526
};
2627
for (let testPath of Object.keys(tests)) {

‎src/test/flutter_debug/debugger_type.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ describe(`flutter debugger`, () => {
2727
"lib/temp1_test.dart": DebuggerType.Flutter,
2828
"lib/temp2_test.dart*": DebuggerType.FlutterTest, // Special case for allowTestsOutsideTestFolder
2929
"test/temp_test.dart": DebuggerType.FlutterTest,
30-
// TODO(dantup): This is broken. https://github.com/Dart-Code/Dart-Code/issues/4809
31-
// "test/tool/temp_tool.dart": DebuggerType.FlutterTest,
30+
"test/tool/temp_tool_test.dart": DebuggerType.FlutterTest,
3231
"tool/temp_tool.dart": DebuggerType.Dart,
3332
};
3433
for (let testPath of Object.keys(tests)) {

0 commit comments

Comments
 (0)