Added get indentation level and line number hotkey

This commit is contained in:
cdw0311 2021-11-16 15:12:57 -06:00
parent ed6df007fd
commit 46fef452d8
2 changed files with 48 additions and 1 deletions

View File

@ -56,6 +56,10 @@
{
"command": "mind-reader.runCursorContext",
"title": "Run Cursor Context"
},
{
"command": "mind-reader.getIndent",
"title": "Get Line Indentation"
}
],
@ -153,8 +157,19 @@
"command": "mind-reader.navigateForward",
"key": "Ctrl+Shift+-",
"mac": ""
},
{
"command": "mind-reader.selectTheme",
"key": "Ctrl+Shift+1",
"mac": ""
},
{
"command": "mind-reader.getIndent",
"key": "Shift+Tab",
"mac": ""
}
],
"menus": {
"editor/context": [

View File

@ -117,6 +117,10 @@ const commands: Command[] = [
{
name: 'mind-reader.runCursorContext',
callback: runCursorContext
},
{
name: 'mind-reader.getIndent',
callback: getIndent
}
];
@ -146,6 +150,34 @@ function resetEditorScale(): void {
vscode.commands.executeCommand('workbench.action.zoomReset');
}
function getIndent(): void {
let editor = vscode.window.activeTextEditor;
if(editor)
{
let tabSize = editor.options.tabSize;
let editorText = editor?.document.getText();
let lineNum = editor.selection.active.line + 1;
let textLine = editor.document.lineAt(lineNum - 1);
let i = 0;
if(textLine.isEmptyOrWhitespace)
{
vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty")
}
else
{
while(textLine.text[i] == '\t')
{
i++;
}
vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Indentation " + i.toString())
}
}
else{
vscode.window.showErrorMessage('No document currently active')
}
}
function runLineContext(): void {
let editor = vscode.window.activeTextEditor;
if (editor) {