mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
js -> ts migration
.js files ended up getting uploaded, beginnings of attempting to fix that mistake. Migrating changes made in .js file to .ts file
This commit is contained in:
parent
125cf15a68
commit
96bca9a601
@ -1,5 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
exports.textCommands = void 0;
|
exports.textCommands = void 0;
|
||||||
|
|
||||||
const vscode = require("vscode");
|
const vscode = require("vscode");
|
||||||
@ -49,8 +51,7 @@ function getLineNumber() {
|
|||||||
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,9 +64,8 @@ function getIndent() {
|
|||||||
let textLine = fetchTextLine(editor);
|
let textLine = fetchTextLine(editor);
|
||||||
|
|
||||||
if (textLine.isEmptyOrWhitespace) {
|
if (textLine.isEmptyOrWhitespace) {
|
||||||
vscode.window.showInformationMessage(`"Line ${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
|
||||||
let tabFmt = {
|
let tabFmt = {
|
||||||
size: editor.options.tabSize,
|
size: editor.options.tabSize,
|
||||||
@ -73,13 +73,12 @@ function getIndent() {
|
|||||||
};
|
};
|
||||||
let i = pl.Lexer.getIndent(textLine.text, tabFmt);
|
let i = pl.Lexer.getIndent(textLine.text, tabFmt);
|
||||||
|
|
||||||
// Ternary operator to change the tense of 'indent' to 'indents' for the output if i is greater than 1
|
/* Ternary operator to change the tense of 'indent' to 'indents' for the output if i is 0 or greater than 1 */
|
||||||
(i > 1) ?
|
(i !== 1) ?
|
||||||
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`) :
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`):
|
||||||
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indent`);
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indent`);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
vscode.window.showErrorMessage('No document currently active');
|
vscode.window.showErrorMessage('No document currently active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,8 +108,7 @@ function getLeadingSpaces() {
|
|||||||
|
|
||||||
if (textLine.isEmptyOrWhitespace) {
|
if (textLine.isEmptyOrWhitespace) {
|
||||||
vscode.window.showInformationMessage(`Line ${lineNum.toString()} is empty`);
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()} is empty`);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/*
|
/*
|
||||||
* set true to use method 1: find the number of leading spaces through arithmetic
|
* set true to use method 1: find the number of leading spaces through arithmetic
|
||||||
* set false to use method 2: find the index position of the first non-whitespace character in a 0-index
|
* set false to use method 2: find the index position of the first non-whitespace character in a 0-index
|
||||||
@ -122,13 +120,12 @@ function getLeadingSpaces() {
|
|||||||
pl.Lexer.getLeadingSpacesByArithmetic(textLine) :
|
pl.Lexer.getLeadingSpacesByArithmetic(textLine) :
|
||||||
pl.Lexer.getLeadingSpacesByIndex(textLine);
|
pl.Lexer.getLeadingSpacesByIndex(textLine);
|
||||||
|
|
||||||
/* Ternary operator to change the tense of 'space' to 'spaces' for the output if numSpaces is greater than 1 */
|
/* Ternary operator to change the tense of 'space' to 'spaces' for the output if numSpaces is 0 or greater than 1 */
|
||||||
(numSpaces > 1) ?
|
(numSpaces !== 1) ?
|
||||||
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`) :
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`):
|
||||||
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space`);
|
vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space`);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
vscode.window.showErrorMessage('No document currently active');
|
vscode.window.showErrorMessage('No document currently active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,15 +141,17 @@ function runLineContext() {
|
|||||||
let size = parseInt(editor.options.tabSize);
|
let size = parseInt(editor.options.tabSize);
|
||||||
let hard = !editor.options.insertSpaces;
|
let hard = !editor.options.insertSpaces;
|
||||||
// initialize parser
|
// initialize parser
|
||||||
let parser = new pl.Parser(editorText, { size, hard });
|
let parser = new pl.Parser(editorText, {
|
||||||
|
size,
|
||||||
|
hard
|
||||||
|
});
|
||||||
parser.parse();
|
parser.parse();
|
||||||
let context = parser.context(line);
|
let context = parser.context(line);
|
||||||
// build text
|
// build text
|
||||||
let contentString = createContextString(context, line);
|
let contentString = createContextString(context, line);
|
||||||
|
|
||||||
vscode.window.showInformationMessage(contentString);
|
vscode.window.showInformationMessage(contentString);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
vscode.window.showErrorMessage('No document currently active');
|
vscode.window.showErrorMessage('No document currently active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,8 +211,7 @@ function runCursorContext() {
|
|||||||
if (col < leadingWS) {
|
if (col < leadingWS) {
|
||||||
// move effective start to first non-whitespace character in the line
|
// move effective start to first non-whitespace character in the line
|
||||||
col = leadingWS;
|
col = leadingWS;
|
||||||
}
|
} else if (col > leadingWS + trimmedText.length - 1) {
|
||||||
else if (col > leadingWS + trimmedText.length - 1) {
|
|
||||||
// move effective end to last non-whitespace character in the line
|
// move effective end to last non-whitespace character in the line
|
||||||
col = leadingWS + trimmedText.length - 1;
|
col = leadingWS + trimmedText.length - 1;
|
||||||
}
|
}
|
||||||
@ -225,7 +223,11 @@ function runCursorContext() {
|
|||||||
while (pos < maxPos && trimmedText.length > 0) {
|
while (pos < maxPos && trimmedText.length > 0) {
|
||||||
let word = trimmedText.replace(/ .*/, '');
|
let word = trimmedText.replace(/ .*/, '');
|
||||||
|
|
||||||
spaceWords.push({ word, start: pos, end: pos + word.length });
|
spaceWords.push({
|
||||||
|
word,
|
||||||
|
start: pos,
|
||||||
|
end: pos + word.length
|
||||||
|
});
|
||||||
// remove processed word from trimmed text
|
// remove processed word from trimmed text
|
||||||
const oldText = trimmedText;
|
const oldText = trimmedText;
|
||||||
trimmedText = trimmedText.replace(/[^ ]+/, '').trimStart();
|
trimmedText = trimmedText.replace(/[^ ]+/, '').trimStart();
|
||||||
@ -233,7 +235,8 @@ function runCursorContext() {
|
|||||||
pos += oldText.length - trimmedText.length;
|
pos += oldText.length - trimmedText.length;
|
||||||
}
|
}
|
||||||
// find word the user is in
|
// find word the user is in
|
||||||
let contextStart = -1, contextEnd = -1;
|
let contextStart = -1,
|
||||||
|
contextEnd = -1;
|
||||||
|
|
||||||
for (let i = 0; i < spaceWords.length; i++) {
|
for (let i = 0; i < spaceWords.length; i++) {
|
||||||
if (col >= spaceWords[i].start && col <= spaceWords[i].end) {
|
if (col >= spaceWords[i].start && col <= spaceWords[i].end) {
|
||||||
|
Loading…
Reference in New Issue
Block a user