@@ -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
0 commit comments