Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Extension/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"editor.formatOnSave": true,
"files.insertFinalNewline": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
"source.fixAll.eslint": "explicit",
Comment thread
bobbrow marked this conversation as resolved.
"source.organizeImports": "explicit"
},
},
"eslint.format.enable": true,
Expand Down
10 changes: 5 additions & 5 deletions Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,16 +1162,16 @@ abstract class DefaultConfigurationProvider implements IConfigurationAssetProvid

class WindowsConfigurationProvider extends DefaultConfigurationProvider {
private executable: string = "a.exe";
private pipeProgram: string = "<" + localize("path.to.pipe.program", "full path to pipe program such as {0}", "plink.exe").replace(/\"/g, "\\\"") + ">";
private pipeProgram: string = "<" + localize("path.to.pipe.program", "full path to pipe program such as {0}", "plink.exe").replace(/"/g, '\\"') + ">";
Comment thread
bobbrow marked this conversation as resolved.
private MIMode: string = 'gdb';
private setupCommandsBlock: string = `"setupCommands": [
{
"description": "${localize("enable.pretty.printing", "Enable pretty-printing for {0}", "gdb").replace(/\"/g, "\\\"")}",
"description": "${localize("enable.pretty.printing", "Enable pretty-printing for {0}", "gdb").replace(/"/g, '\\"')}",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "${localize("enable.intel.disassembly.flavor", "Set Disassembly Flavor to {0}", "Intel").replace(/\"/g, "\\\"")}",
"description": "${localize("enable.intel.disassembly.flavor", "Set Disassembly Flavor to {0}", "Intel").replace(/"/g, '\\"')}",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
Expand Down Expand Up @@ -1205,12 +1205,12 @@ class LinuxConfigurationProvider extends DefaultConfigurationProvider {
private MIMode: string = 'gdb';
private setupCommandsBlock: string = `"setupCommands": [
{
"description": "${localize("enable.pretty.printing", "Enable pretty-printing for {0}", "gdb").replace(/\"/g, "\\\"")}",
"description": "${localize("enable.pretty.printing", "Enable pretty-printing for {0}", "gdb").replace(/"/g, '\\"')}",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "${localize("enable.intel.disassembly.flavor", "Set Disassembly Flavor to {0}", "Intel").replace(/\"/g, "\\\"")}",
"description": "${localize("enable.intel.disassembly.flavor", "Set Disassembly Flavor to {0}", "Intel").replace(/"/g, '\\"')}",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
Expand Down
38 changes: 19 additions & 19 deletions Extension/src/Debugger/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function createLaunchString(name: string, type: string, executable: string): str
return `"name": "${name}",
"type": "${type}",
"request": "launch",
"program": "${localize("enter.program.name", "enter program name, for example {0}", "$\{workspaceFolder\}" + "/" + executable).replace(/\"/g, "\\\"")}",
"program": "${localize("enter.program.name", "enter program name, for example {0}", "$\{workspaceFolder\}" + "/" + executable).replace(/"/g, '\\"')}",
"args": [],
"stopAtEntry": false,
"cwd": "$\{fileDirname\}",
Expand All @@ -106,15 +106,15 @@ function createAttachString(name: string, type: string, executable: string): str
"name": "${name}",
"type": "${type}",
"request": "attach",{0}
`, [type === "cppdbg" ? `${os.EOL}"program": "${localize("enter.program.name", "enter program name, for example {0}", "$\{workspaceFolder\}" + "/" + executable).replace(/\"/g, "\\\"")}",` : ""]);
`, [type === "cppdbg" ? `${os.EOL}"program": "${localize("enter.program.name", "enter program name, for example {0}", "$\{workspaceFolder\}" + "/" + executable).replace(/"/g, '\\"')}",` : ""]);
}

function createRemoteAttachString(name: string, type: string, executable: string): string {
return `
"name": "${name}",
"type": "${type}",
"request": "attach",
"program": "${localize("enter.program.name", "enter program name, for example {0}", "$\{workspaceFolder\}" + "/" + executable).replace(/\"/g, "\\\"")}",
"program": "${localize("enter.program.name", "enter program name, for example {0}", "$\{workspaceFolder\}" + "/" + executable).replace(/"/g, '\\"')}",
"processId": "$\{command:pickRemoteProcess\}"
`;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ abstract class Configuration implements IConfiguration {
export class MIConfigurations extends Configuration {

public GetLaunchConfiguration(): IConfigurationSnippet {
const name: string = `(${this.MIMode}) ${localize("launch.string", "Launch").replace(/\"/g, "\\\"")}`;
const name: string = `(${this.MIMode}) ${localize("launch.string", "Launch").replace(/"/g, '\\"')}`;

const body: string = formatString(`{
\t${indentJsonString(createLaunchString(name, this.miDebugger, this.executable))},
Expand All @@ -168,15 +168,15 @@ export class MIConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("launch.with", "Launch with {0}.", this.MIMode).replace(/\"/g, "\\\""),
"description": localize("launch.with", "Launch with {0}.", this.MIMode).replace(/"/g, '\\"'),
"bodyText": body.trim(),
"isInitialConfiguration": true,
"debuggerType": DebuggerType.cppdbg
};
}

public GetAttachConfiguration(): IConfigurationSnippet {
const name: string = `(${this.MIMode}) ${localize("attach.string", "Attach").replace(/\"/g, "\\\"")}`;
const name: string = `(${this.MIMode}) ${localize("attach.string", "Attach").replace(/"/g, '\\"')}`;

const body: string = formatString(`{
\t${indentJsonString(createAttachString(name, this.miDebugger, this.executable))}
Expand All @@ -186,7 +186,7 @@ export class MIConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("attach.with", "Attach with {0}.", this.MIMode).replace(/\"/g, "\\\""),
"description": localize("attach.with", "Attach with {0}.", this.MIMode).replace(/"/g, '\\"'),
"bodyText": body.trim(),
"debuggerType": DebuggerType.cppdbg
};
Expand All @@ -197,7 +197,7 @@ export class MIConfigurations extends Configuration {
export class PipeTransportConfigurations extends Configuration {

public GetLaunchConfiguration(): IConfigurationSnippet {
const name: string = `(${this.MIMode}) ${localize("pipe.launch", "Pipe Launch").replace(/\"/g, "\\\"")}`;
const name: string = `(${this.MIMode}) ${localize("pipe.launch", "Pipe Launch").replace(/"/g, '\\"')}`;

const body: string = formatString(`
{
Expand All @@ -208,15 +208,15 @@ export class PipeTransportConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("pipe.launch.with", "Pipe Launch with {0}.", this.MIMode).replace(/\"/g, "\\\""),
"description": localize("pipe.launch.with", "Pipe Launch with {0}.", this.MIMode).replace(/"/g, '\\"'),
"bodyText": body.trim(),
"debuggerType": DebuggerType.cppdbg
};

}

public GetAttachConfiguration(): IConfigurationSnippet {
const name: string = `(${this.MIMode}) ${localize("pipe.attach", "Pipe Attach").replace(/\"/g, "\\\"")}`;
const name: string = `(${this.MIMode}) ${localize("pipe.attach", "Pipe Attach").replace(/"/g, '\\"')}`;

const body: string = formatString(`
{
Expand All @@ -226,7 +226,7 @@ export class PipeTransportConfigurations extends Configuration {
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
return {
"label": configPrefix + name,
"description": localize("pipe.attach.with", "Pipe Attach with {0}.", this.MIMode).replace(/\"/g, "\\\""),
"description": localize("pipe.attach.with", "Pipe Attach with {0}.", this.MIMode).replace(/"/g, '\\"'),
"bodyText": body.trim(),
"debuggerType": DebuggerType.cppdbg
};
Expand All @@ -237,7 +237,7 @@ export class PipeTransportConfigurations extends Configuration {
export class WindowsConfigurations extends Configuration {

public GetLaunchConfiguration(): IConfigurationSnippet {
const name: string = `(Windows) ${localize("launch.string", "Launch").replace(/\"/g, "\\\"")}`;
const name: string = `(Windows) ${localize("launch.string", "Launch").replace(/"/g, '\\"')}`;

const body: string = `
{
Expand All @@ -246,7 +246,7 @@ export class WindowsConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("launch.with.vs.debugger", "Launch with the Visual Studio C/C++ debugger.").replace(/\"/g, "\\\""),
"description": localize("launch.with.vs.debugger", "Launch with the Visual Studio C/C++ debugger.").replace(/"/g, '\\"'),
"bodyText": body.trim(),
"isInitialConfiguration": true,
"debuggerType": DebuggerType.cppvsdbg
Expand All @@ -255,7 +255,7 @@ export class WindowsConfigurations extends Configuration {
}

public GetAttachConfiguration(): IConfigurationSnippet {
const name: string = `(Windows) ${localize("attach.string", "Attach").replace(/\"/g, "\\\"")}`;
const name: string = `(Windows) ${localize("attach.string", "Attach").replace(/"/g, '\\"')}`;

const body: string = `
{
Expand All @@ -264,7 +264,7 @@ export class WindowsConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("attach.with.vs.debugger", "Attach to a process with the Visual Studio C/C++ debugger.").replace(/\"/g, "\\\""),
"description": localize("attach.with.vs.debugger", "Attach to a process with the Visual Studio C/C++ debugger.").replace(/"/g, '\\"'),
"bodyText": body.trim(),
"debuggerType": DebuggerType.cppvsdbg
};
Expand All @@ -277,7 +277,7 @@ export class WSLConfigurations extends Configuration {
public bashPipeProgram = process.arch === 'ia32' ? "${env:windir}\\\\sysnative\\\\bash.exe" : "${env:windir}\\\\system32\\\\bash.exe";

public GetLaunchConfiguration(): IConfigurationSnippet {
const name: string = `(${this.MIMode}) ${localize("bash.on.windows.launch", "Bash on Windows Launch").replace(/\"/g, "\\\"")}`;
const name: string = `(${this.MIMode}) ${localize("bash.on.windows.launch", "Bash on Windows Launch").replace(/"/g, '\\"')}`;

const body: string = formatString(`
{
Expand All @@ -287,14 +287,14 @@ export class WSLConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("launch.bash.windows", "Launch in Bash on Windows using {0}.", this.MIMode).replace(/\"/g, "\\\""),
"description": localize("launch.bash.windows", "Launch in Bash on Windows using {0}.", this.MIMode).replace(/"/g, '\\"'),
"bodyText": body.trim(),
"debuggerType": DebuggerType.cppdbg
};
}

public GetAttachConfiguration(): IConfigurationSnippet {
const name: string = `(${this.MIMode}) ${localize("bash.on.windows.attach", "Bash on Windows Attach").replace(/\"/g, "\\\"")}`;
const name: string = `(${this.MIMode}) ${localize("bash.on.windows.attach", "Bash on Windows Attach").replace(/"/g, '\\"')}`;

const body: string = formatString(`
{
Expand All @@ -304,7 +304,7 @@ export class WSLConfigurations extends Configuration {

return {
"label": configPrefix + name,
"description": localize("remote.attach.bash.windows", "Attach to a remote process running in Bash on Windows using {0}.", this.MIMode).replace(/\"/g, "\\\""),
"description": localize("remote.attach.bash.windows", "Attach to a remote process running in Bash on Windows using {0}.", this.MIMode).replace(/"/g, '\\"'),
"bodyText": body.trim(),
"debuggerType": DebuggerType.cppdbg
};
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/Debugger/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ArchitectureReplacer {
public static checkAndReplaceWSLPipeProgram(pipeProgramStr: string, expectedArch: ArchType): string | undefined {
let replacedPipeProgram: string | undefined;
const winDir: string | undefined = process.env.WINDIR ? process.env.WINDIR.toLowerCase() : undefined;
const winDirAltDirSep: string | undefined = process.env.WINDIR ? process.env.WINDIR.replace('\\', '/').toLowerCase() : undefined;
const winDirAltDirSep: string | undefined = process.env.WINDIR ? process.env.WINDIR.replace(/\\/g, '/').toLowerCase() : undefined;
const winDirEnv: string = "${env:windir}";

if (winDir && winDirAltDirSep && (pipeProgramStr.indexOf(winDir) === 0 || pipeProgramStr.indexOf(winDirAltDirSep) === 0 || pipeProgramStr.indexOf(winDirEnv) === 0)) {
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ export class CppProperties {

// Escape the path string for literal use in a regular expression
// Need to escape any quotes to match the original text
let escapedPath: string = curPath.replace(/\"/g, '\\\"');
let escapedPath: string = curPath.replace(/"/g, '\\"');
escapedPath = escapedPath.replace(/[-\"\/\\^$*+?.()|[\]{}]/g, '\\$&');

// Create a pattern to search for the path with either a quote or semicolon immediately before and after,
Expand Down
3 changes: 2 additions & 1 deletion Extension/src/LanguageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as semver from 'semver';
import { quote } from 'shell-quote';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import * as which from 'which';
Expand Down Expand Up @@ -278,7 +279,7 @@ export class CppSettings extends Settings {
let clangVersion: string;
try {
const exePath: string = getExtensionFilePath(`./LLVM/bin/${clangName}`);
const output: string[] = execSync(`${exePath} --version`).toString().split(" ");
const output: string[] = execSync(quote([exePath, '--version'])).toString().split(" ");
if (output.length < 3 || output[0] !== clangStr || output[1] !== "version" || !semver.valid(output[2])) {
if (output.length === 3) {
return path;
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/Utility/Text/taggedLiteral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isIdentifierPart, isIdentifierStart } from './characterCodes';

/** simple dynamic tagged literal implementation */
export function taggedLiteral(templateString: string, templateVars: Record<string, any>): string {
return safeEval(`\`${templateString.replace('\\', '\\\\').replace(/`/, '\`')}\`;`, templateVars) as string;
return safeEval(`\`${templateString.replace(/\\/g, '\\\\').replace(/`/g, '\`')}\`;`, templateVars) as string;
}

function parseTaggedLiteral(templateString: string) {
Expand Down
2 changes: 1 addition & 1 deletion Extension/ui/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class SettingsApp {
private showErrorWithInfo(elementID: string, errorInfo: string): void {
this.showElement(elementID, errorInfo ? true : false);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
document.getElementById(elementID)!.innerHTML = errorInfo ? errorInfo : "";
document.getElementById(elementID)!.textContent = errorInfo ? errorInfo : "";
}

private updateConfigSelection(message: any): void {
Expand Down