@@ -239,7 +239,8 @@ async function fixPylanceConfig(
239239 // turn typechecking off
240240 // This is a quite distructive change, so we do it on first hit of the run button
241241 // not on-load of the plugin
242- const libDir = context . asAbsolutePath ( 'python/code/' ) ;
242+ const subDir = 'python/code' ;
243+ const libDir = context . asAbsolutePath ( subDir ) ;
243244
244245 const cfg = vscode . workspace . getConfiguration ( 'python' , folder ?. uri ) ;
245246 const target = folder ? vscode . ConfigurationTarget . WorkspaceFolder
@@ -283,9 +284,17 @@ async function fixPylanceConfig(
283284 // extraPaths
284285 const keyExtraPaths = 'analysis.extraPaths' ;
285286 const extra = cfg . get < string [ ] > ( keyExtraPaths ) ?? [ ] ;
286- if ( ! extra . includes ( libDir ) ) {
287- const newExtra = [ ...extra , libDir ] ;
287+ // Filter out old plugin paths (paths containing 'write-your-python-program' but not matching current libDir)
288+ const filtered = extra . filter ( p => {
289+ const isPluginPath = p . includes ( 'stefanwehr.write-your-python-program' ) && p . includes ( subDir ) ;
290+ return ! isPluginPath ;
291+ } ) ;
292+ if ( ! filtered . includes ( libDir ) ) {
293+ const newExtra = [ ...filtered , libDir ] ;
288294 await tryUpdate ( keyExtraPaths , newExtra ) ;
295+ } else if ( filtered . length !== extra . length ) {
296+ // libDir is already present but we removed old paths, so update anyway
297+ await tryUpdate ( keyExtraPaths , filtered ) ;
289298 }
290299
291300 // typechecking off
0 commit comments