Skip to content

Commit 610c635

Browse files
committed
fix: cmd paths when registering
1 parent 87d6e5d commit 610c635

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/features/terminal/startup/cmdStartup.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const regionEnd = 'rem <<< vscode python';
6161

6262
function getActivationContent(key: string): string {
6363
const lineSep = isWindows() ? '\r\n' : '\n';
64-
return ['', '', regionStart, `if defined ${key} (`, ` %${key}%`, ')', regionEnd, ''].join(lineSep);
64+
return ['', '', regionStart, `if defined ${key} (`, ` call "%${key}%"`, ')', regionEnd, ''].join(lineSep);
6565
}
6666

6767
function getMainBatchFileContent(startupFile: string, existingContent?: string): string {
@@ -86,7 +86,7 @@ function getMainBatchFileContent(startupFile: string, existingContent?: string):
8686
return content.join(lineSep);
8787
}
8888

89-
async function checkRegistryAutoRun(regMainBatchFile: string): Promise<boolean> {
89+
async function checkRegistryAutoRun(mainBatchFile: string, regMainBatchFile: string): Promise<boolean> {
9090
if (!isWindows()) {
9191
return false;
9292
}
@@ -98,7 +98,7 @@ async function checkRegistryAutoRun(regMainBatchFile: string): Promise<boolean>
9898
});
9999

100100
// Check if the output contains our batch file path
101-
return stdout.includes(regMainBatchFile);
101+
return stdout.includes(regMainBatchFile) || stdout.includes(mainBatchFile);
102102
} catch {
103103
// If the command fails, the registry key might not exist
104104
return false;
@@ -160,15 +160,18 @@ async function isCmdStartupSetup(cmdFiles: CmdFilePaths, key: string): Promise<b
160160
}
161161

162162
const mainFileExists = await fs.pathExists(cmdFiles.mainBatchFile);
163-
const mainFileHasContent = mainFileExists
164-
? (await fs.readFile(cmdFiles.mainBatchFile, 'utf8')).includes(cmdFiles.regStartupFile)
165-
: false;
163+
let mainFileHasContent = false;
164+
if (mainFileExists) {
165+
const mainFileContent = await fs.readFile(cmdFiles.mainBatchFile, 'utf8');
166+
mainFileHasContent =
167+
mainFileContent.includes(cmdFiles.regStartupFile) || mainFileContent.includes(cmdFiles.startupFile);
168+
}
166169

167170
if (!mainFileHasContent) {
168171
return false;
169172
}
170173

171-
const registrySetup = await checkRegistryAutoRun(cmdFiles.regMainBatchFile);
174+
const registrySetup = await checkRegistryAutoRun(cmdFiles.regMainBatchFile, cmdFiles.mainBatchFile);
172175
return registrySetup;
173176
}
174177

0 commit comments

Comments
 (0)