mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
Switch from string concatination to interpolation
Improves concision.
This commit is contained in:
parent
6915cd5b44
commit
3525963bb0
@ -14,7 +14,7 @@ exports.textCommands = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mind-reader.getLeadingSpaces',
|
name: 'mind-reader.getLeadingSpaces',
|
||||||
callback: getLeadingSpaces,
|
callback: getLeadingSpaces,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mind-reader.runLineContext',
|
name: 'mind-reader.runLineContext',
|
||||||
@ -25,7 +25,7 @@ exports.textCommands = [
|
|||||||
callback: runCursorContext
|
callback: runCursorContext
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
/* Helper Function
|
/* Helper Function
|
||||||
* This function returns the line number of the active text editor window
|
* This function returns the line number of the active text editor window
|
||||||
*/
|
*/
|
||||||
function fetchLineNumber(editor) {
|
function fetchLineNumber(editor) {
|
||||||
@ -35,14 +35,14 @@ function fetchLineNumber(editor) {
|
|||||||
// Function that outputs the current line number the cursor is on
|
// Function that outputs the current line number the cursor is on
|
||||||
function getLineNumber() {
|
function getLineNumber() {
|
||||||
let editor = vscode.window.activeTextEditor;
|
let editor = vscode.window.activeTextEditor;
|
||||||
|
|
||||||
if (editor) {
|
if (editor) {
|
||||||
let lineNum = fetchLineNumber(editor);
|
let lineNum = fetchLineNumber(editor);
|
||||||
vscode.window.showInformationMessage("Line " + lineNum.toString());
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vscode.window.showErrorMessage('No document currently active');
|
vscode.window.showErrorMessage('No document currently active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIndent() {
|
function getIndent() {
|
||||||
@ -51,7 +51,7 @@ function getIndent() {
|
|||||||
let lineNum = fetchLineNumber(editor);
|
let lineNum = fetchLineNumber(editor);
|
||||||
let textLine = editor.document.lineAt(lineNum - 1);
|
let textLine = editor.document.lineAt(lineNum - 1);
|
||||||
if (textLine.isEmptyOrWhitespace) {
|
if (textLine.isEmptyOrWhitespace) {
|
||||||
vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty");
|
vscode.window.showInformationMessage(`"Line ${lineNum.toString()} is Empty`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Grab tab format from open document
|
// Grab tab format from open document
|
||||||
@ -60,7 +60,7 @@ function getIndent() {
|
|||||||
hard: !editor.options.insertSpaces
|
hard: !editor.options.insertSpaces
|
||||||
};
|
};
|
||||||
let i = pl.Lexer.getIndent(textLine.text, tabFmt);
|
let i = pl.Lexer.getIndent(textLine.text, tabFmt);
|
||||||
vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Indentation " + i.toString());
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -78,12 +78,12 @@ function getLeadingSpaces() {
|
|||||||
let lineNum = fetchLineNumber(editor);
|
let lineNum = fetchLineNumber(editor);
|
||||||
let textLine = editor.document.lineAt(lineNum - 1);
|
let textLine = editor.document.lineAt(lineNum - 1);
|
||||||
if(textLine.isEmptyOrWhitespace) {
|
if(textLine.isEmptyOrWhitespace) {
|
||||||
vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty");
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()} is empty`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let numSpaces = textLine.firstNonWhitespaceCharacterIndex;
|
let numSpaces = textLine.firstNonWhitespaceCharacterIndex;
|
||||||
// let numSpaces = textLine.text.length - textLine.text.trimStart().length; // Alternative method, same result by calculating the leading spaces
|
// let numSpaces = textLine.text.length - textLine.text.trimStart().length; // Alternative method, same result by calculating the leading spaces
|
||||||
vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Has " + numSpaces.toString()+ " Leading Spaces ");
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -53,7 +53,7 @@ export default class LineToken {
|
|||||||
* @return A string representation of the token
|
* @return A string representation of the token
|
||||||
*/
|
*/
|
||||||
toString(): string {
|
toString(): string {
|
||||||
return this.type + ", linenr:" + (this.linenr+1) + ", indentLevel: " + this.indentLevel + ", attr: " + this.attr;
|
return `${this.type}, linenr: ${this.linenr+1}, indentLevel: ${this.indentLevel}, attr: ${this.attr}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user