Skip to content

Commit

Permalink
wip: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alashchev17 committed Oct 18, 2024
1 parent 3f23970 commit 8668709
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions src/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,31 +685,30 @@ export class PanelWebview implements vscode.WebviewViewProvider {
}

removeQuestionMarks(filePath: string): string {
// Remove the sequence '\\?\\'
let cleanedPath = filePath.replace(/\\\?\\/g, '');
// Remove leading backslashes if present
cleanedPath = cleanedPath.replace(/^\\+/, '');
// Replace question marks and backslashes
// return cleanedPath.replace(/\?/g, '').replace(/\\/g, '/');
return cleanedPath;
}

async startFileAnimation(fileName: string) {

const openFiles = this.getOpenFiles();
console.log(`[DEBUG]: opened files: `, openFiles);
const editor = vscode.window.activeTextEditor;

const workspaceFolders = vscode.workspace.workspaceFolders;
if (!workspaceFolders) {
return;
}

const workspace_path = workspaceFolders[0].uri.fsPath;
console.log(`[DEBUG]: workspacePath: `, workspace_path);

const workspace_path = workspaceFolders[0].uri.fsPath;
const relative_path = path.relative(workspace_path, fileName.replace(/\?/g, ''));

const normalized_path = this.removeQuestionMarks(fileName);
const uri = vscode.Uri.file(normalized_path);

console.log(`[DEBUG]: (animation) opening file: `, {value: relative_path});

console.log(`[COND]: openFiles.some(file => file.includes(relative_path): ${openFiles.some(file => file.includes(relative_path))}`);
if(!openFiles.some(file => file.includes(relative_path))|| !editor) {return;}
Expand Down Expand Up @@ -738,10 +737,8 @@ export class PanelWebview implements vscode.WebviewViewProvider {
}

const workspace_path = workspaceFolders[0].uri.fsPath;
console.log(`[DEBUG]: workspacePath: `, workspace_path);
const relative_path = path.relative(workspace_path, fileName.replace(/\?/g, ''));

console.log(`[DEBUG]: opening file: `, normalized_path);
console.log(`[COND]: openFiles.some(file => file.includes(relative_path): ${openFiles.some(file => file.includes(relative_path))}`);
if(!openFiles.some(file => file.includes(relative_path))|| !editor) {return;}

Expand Down Expand Up @@ -840,32 +837,11 @@ export class PanelWebview implements vscode.WebviewViewProvider {


async handleOpenFile(file: {file_name:string, line?: number}) {
//

// const workspaceFolders = vscode.workspace.workspaceFolders;
// let relative_path: string = "";
// let workspace_path: string = "";
// if (workspaceFolders) {
// workspace_path = workspaceFolders[0].uri.fsPath;
// console.log(`[DEBUG]: workspacePath: `, workspace_path);
// relative_path = path.relative(workspace_path, file.file_name.replace(/\?/g, ''));
// }

function removeQuestionMarks(filePath: string): string {
// Remove the sequence '\\?\\'
let cleanedPath = filePath.replace(/\\\?\\/g, '');
// Remove leading backslashes if present
cleanedPath = cleanedPath.replace(/^\\+/, '');
// Replace question marks and backslashes
return cleanedPath.replace(/\?/g, '').replace(/\\/g, '/');
}

const normalized_path = removeQuestionMarks(file.file_name);

console.log(`[DEBUG]: opening file: `, normalized_path);
const normalized_path = this.removeQuestionMarks(file.file_name);

const uri = vscode.Uri.file(normalized_path);
const document = await vscode.workspace.openTextDocument(uri);

if(file.line !== undefined) {
const position = new vscode.Position(file.line ?? 0, 0);
const editor = await vscode.window.showTextDocument(document);
Expand Down

0 comments on commit 8668709

Please sign in to comment.