## 1.4.3
This commit is contained in:
parent
fb3c5c7a23
commit
bf07ffc3b8
@ -92,4 +92,10 @@ None
|
||||
## 1.4.2
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Insert date time
|
||||
- Insert date time
|
||||
|
||||
## 1.4.3
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Moved Insert date time
|
||||
- Transform to Popper Case
|
@ -4,7 +4,7 @@
|
||||
"description": "Helper for VS Code in TypeScript",
|
||||
"publisher": "IFX",
|
||||
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"engines": {
|
||||
"vscode": "^1.79.0"
|
||||
},
|
||||
@ -23,6 +23,14 @@
|
||||
"command": "promiseLinesHelper.codeGeneratorQuickPick",
|
||||
"title": "Code Generator - Quick Pick"
|
||||
},
|
||||
{
|
||||
"command": "promiseLinesHelper.insertDateTime",
|
||||
"title": "Insert DateTime"
|
||||
},
|
||||
{
|
||||
"command": "promiseLinesHelper.transformToPopperCase",
|
||||
"title": "Transform to Popper Case"
|
||||
},
|
||||
{
|
||||
"command": "readOnlyLinesHelper.searchGoogle",
|
||||
"title": "Search Google"
|
||||
@ -51,10 +59,6 @@
|
||||
"command": "replaceLinesHelper.expandSql",
|
||||
"title": "Expand Sql"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.insertDateTime",
|
||||
"title": "Insert DateTime"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.listToListFamily",
|
||||
"title": "List to list family (Kristy, Mike ...)"
|
||||
|
@ -26,6 +26,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
const commands = [
|
||||
vscode.commands.registerCommand('promiseLinesHelper.codeGeneratorQuickPick', promiseLinesHelper.codeGeneratorQuickPick),
|
||||
vscode.commands.registerCommand('promiseLinesHelper.insertDateTime', promiseLinesHelper.insertDateTime),
|
||||
vscode.commands.registerCommand('promiseLinesHelper.transformToPopperCase', promiseLinesHelper.transformToPopperCase),
|
||||
vscode.commands.registerCommand('readOnlyLinesHelper.searchGoogle', readOnlyLinesHelper.searchGoogle),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.addCSharpComment', replaceLinesHelper.addCSharpComment),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.addVBComment', replaceLinesHelper.addVBComment),
|
||||
@ -33,7 +35,6 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('replaceLinesHelper.cutEachLine', replaceLinesHelper.cutEachLine),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.distinctLines', replaceLinesHelper.distinctLines),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.expandSql', replaceLinesHelper.expandSql),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.insertDateTime', replaceLinesHelper.insertDateTime),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql),
|
||||
|
@ -128,4 +128,55 @@ function codeGeneratorQuickPickLogic(): undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export const codeGeneratorQuickPick = () => codeGeneratorQuickPickLogic();
|
||||
function insertDateTimeLogic(): undefined {
|
||||
const textEditor = vscode.window.activeTextEditor;
|
||||
if (!textEditor) {
|
||||
return undefined;
|
||||
}
|
||||
const date = new Date();
|
||||
const selection = textEditor.selection;
|
||||
textEditor.edit(editBuilder => {
|
||||
var range;
|
||||
if (selection.isEmpty) {
|
||||
editBuilder.insert(selection.start, date.toString())
|
||||
}
|
||||
else {
|
||||
range = new vscode.Range(selection.start.line, selection.start.character, selection.end.line, selection.end.character);
|
||||
editBuilder.replace(range, date.toString());
|
||||
}
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function camelCase(str: string) {
|
||||
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
|
||||
if (+match === 0) return "";
|
||||
return index === 0 ? match.toLowerCase() : match.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function transformToPopperCaseLogic(): undefined {
|
||||
const textEditor = vscode.window.activeTextEditor;
|
||||
if (!textEditor) {
|
||||
return undefined;
|
||||
}
|
||||
const selection = textEditor.selection;
|
||||
textEditor.edit(editBuilder => {
|
||||
var range;
|
||||
if (selection.isEmpty) {
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
range = new vscode.Range(selection.start.line, selection.start.character, selection.end.line, selection.end.character);
|
||||
const highlighted = textEditor.document.getText(range);
|
||||
let camelCased = camelCase(highlighted);
|
||||
let properCased = camelCased.substring(0, 1).toUpperCase() + camelCased.substring(1, camelCased.length);
|
||||
editBuilder.replace(range, properCased);
|
||||
}
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export const codeGeneratorQuickPick = () => codeGeneratorQuickPickLogic();
|
||||
export const insertDateTime = () => insertDateTimeLogic();
|
||||
export const transformToPopperCase = () => transformToPopperCaseLogic();
|
@ -10,7 +10,6 @@ enum LinesAction {
|
||||
cutEachLine,
|
||||
distinctLines,
|
||||
expandSql,
|
||||
insertDateTime,
|
||||
listToListFamily,
|
||||
listToListWrappedComma,
|
||||
prettySql,
|
||||
@ -119,13 +118,6 @@ function expandSqlLogic(lines: string[]): void {
|
||||
prettySqlLogic(lines);
|
||||
}
|
||||
|
||||
function insertDateTimeLogic(lines: string[]): void {
|
||||
const date = new Date();
|
||||
for (let i = 0; i < lines.length; ++i) {
|
||||
lines[i] = date.toString();
|
||||
}
|
||||
}
|
||||
|
||||
function listToListFamilyLogic(lines: string[]): void {
|
||||
for (let i = 0; i < lines.length; ++i) {
|
||||
lines[i] = "Kristy" + lines[i].trim() + "Mike" + lines[i].trim() + "Jason" + lines[i].trim() + "Mackenzie" + lines[i].trim() + "Logan" + lines[i].trim() + "Lilly" + lines[i].trim() + "Chelsea" + lines[i].trim() + "Piper" + lines[i].trim();
|
||||
@ -410,7 +402,6 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
|
||||
case LinesAction.cutEachLine: { cutEachLineLogic(lines); break; }
|
||||
case LinesAction.distinctLines: { distinctLinesLogic(lines); break; }
|
||||
case LinesAction.expandSql: { expandSqlLogic(lines); break; }
|
||||
case LinesAction.insertDateTime: { insertDateTimeLogic(lines); break; }
|
||||
case LinesAction.listToListFamily: { listToListFamilyLogic(lines); break; }
|
||||
case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; }
|
||||
case LinesAction.prettySql: { prettySqlLogic(lines); break; }
|
||||
@ -437,7 +428,6 @@ export const convertToRegularExpression = () => linesFunction(LinesAction.conver
|
||||
export const cutEachLine = () => linesFunction(LinesAction.cutEachLine);
|
||||
export const distinctLines = () => linesFunction(LinesAction.distinctLines);
|
||||
export const expandSql = () => linesFunction(LinesAction.expandSql);
|
||||
export const insertDateTime = () => linesFunction(LinesAction.insertDateTime);
|
||||
export const listToListFamily = () => linesFunction(LinesAction.listToListFamily);
|
||||
export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma);
|
||||
export const prettySql = () => linesFunction(LinesAction.prettySql);
|
||||
|
Loading…
x
Reference in New Issue
Block a user