Skip to content

Commit

Permalink
update ci and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
omergulen committed Aug 27, 2024
1 parent 6fe19b9 commit f82700c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 115 deletions.
93 changes: 54 additions & 39 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,65 @@ import * as vscode from 'vscode';
import { getLogStatementWithText } from './helpers';

export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "Universal Console Utils" is now active!');
console.log(
'Congratulations, your extension "Universal Console Utils" is now active!'
);

const insertLogStatement = vscode.commands.registerCommand('universal-console-utils.insertLogStatement', () => {
const insertLogStatement = vscode.commands.registerCommand(
'universal-console-utils.insertLogStatement',
() => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}

const editor = vscode.window.activeTextEditor;
if (!editor) { return; }

const text = editor.selections.map((sel: vscode.Selection) =>
editor.document.getText(sel)
);
vscode.commands.executeCommand('editor.action.insertLineAfter')
.then<void>(() => {
text.reduce((acc: Promise<any>, _text: string, index: number) => {
return acc.then(res => {
return new Promise<void>(resolve => {
const logToInsert = getLogStatementWithText(_text, editor.document.languageId);
const range = new vscode.Range(editor.selections[index].start, editor.selections[index].end);
editor.edit((editBuilder: vscode.TextEditorEdit) => {
editBuilder.replace(range, logToInsert);
}).then(() => resolve());
});
});
}, Promise.resolve());
})
.then(() => cursorPlacement());
return;
});
context.subscriptions.push(insertLogStatement);
const text = editor.selections.map((sel: vscode.Selection) =>
editor.document.getText(sel)
);
vscode.commands
.executeCommand('editor.action.insertLineAfter')
.then<void>(() => {
text.reduce((acc: Promise<any>, _text: string, index: number) => {
return acc.then((res) => {
return new Promise<void>((resolve) => {
const logToInsert = getLogStatementWithText(
_text,
editor.document.languageId
);
const range = new vscode.Range(
editor.selections[index].start,
editor.selections[index].end
);
editor
.edit((editBuilder: vscode.TextEditorEdit) => {
editBuilder.replace(range, logToInsert);
})
.then(() => resolve());
});
});
}, Promise.resolve());
})
.then(() => cursorPlacement());
return;
}
);
context.subscriptions.push(insertLogStatement);
}

function cursorPlacement() {
// release the selection caused by inserting
vscode.commands.executeCommand('cursorMove', {
to: 'right',
by: 'line',
value: 1
});
// position the cursor inside the parenthesis
vscode.commands.executeCommand('cursorMove', {
to: 'left',
by: 'line',
value: 1
});
// release the selection caused by inserting
vscode.commands.executeCommand('cursorMove', {
to: 'right',
by: 'line',
value: 1,
});
// position the cursor inside the parenthesis
vscode.commands.executeCommand('cursorMove', {
to: 'left',
by: 'line',
value: 1,
});
}

// this method is called when your extension is deactivated
export function deactivate() { }
export function deactivate() {}
23 changes: 0 additions & 23 deletions src/test/runTest.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/suite/extension.test.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/test/suite/index.ts

This file was deleted.

0 comments on commit f82700c

Please sign in to comment.