From 46fef452d83df8aefeb009e0baa19b70a7b76cb9 Mon Sep 17 00:00:00 2001 From: cdw0311 Date: Tue, 16 Nov 2021 15:12:57 -0600 Subject: [PATCH 1/5] Added get indentation level and line number hotkey --- package.json | 17 ++++++++++++++++- src/commands.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c38aec..b7a7e4f 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/commands.ts b/src/commands.ts index 6a6a976..2c5faef 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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) { From 0dce1dde237052aa0b4ddc1367ae37d0a238a858 Mon Sep 17 00:00:00 2001 From: cdw0311 Date: Tue, 16 Nov 2021 15:17:41 -0600 Subject: [PATCH 2/5] Added current indentation level and line number hotkey --- src/commands.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 2c5faef..db4c273 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -154,8 +154,6 @@ 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; From f59be64ab239295a509864e937ccc571472fe918 Mon Sep 17 00:00:00 2001 From: CalWooten95 Date: Tue, 16 Nov 2021 15:21:57 -0600 Subject: [PATCH 3/5] Update commands.ts --- src/commands.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index db4c273..1d0a1d8 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -159,19 +159,19 @@ function getIndent(): void { let i = 0; if(textLine.isEmptyOrWhitespace) { - vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty") + vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty"); } else { - while(textLine.text[i] == '\t') + while(textLine.text[i] === '\t') { i++; } - vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Indentation " + i.toString()) + vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Indentation " + i.toString()); } } else{ - vscode.window.showErrorMessage('No document currently active') + vscode.window.showErrorMessage('No document currently active'); } } From 327ce1eea4aaf80fb647664ba39cf672d3b2fde0 Mon Sep 17 00:00:00 2001 From: CalWooten95 Date: Tue, 16 Nov 2021 15:24:41 -0600 Subject: [PATCH 4/5] Update commands.ts --- src/commands.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 1d0a1d8..b97abff 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -152,7 +152,7 @@ function resetEditorScale(): void { function getIndent(): void { let editor = vscode.window.activeTextEditor; - if(editor) + if(editor) { let lineNum = editor.selection.active.line + 1; let textLine = editor.document.lineAt(lineNum - 1); @@ -178,7 +178,7 @@ function getIndent(): void { function runLineContext(): void { let editor = vscode.window.activeTextEditor; - if (editor) { + if (editor){ // current text and line number let editorText = editor.document.getText(); let line = editor.selection.active.line; From 7f2181d9eacd88a94d1c175df7287a720c5e6922 Mon Sep 17 00:00:00 2001 From: CalWooten95 Date: Wed, 17 Nov 2021 16:32:35 -0600 Subject: [PATCH 5/5] Update commands.ts --- src/commands.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index b97abff..596c082 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -156,17 +156,18 @@ function getIndent(): void { { 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++; - } + // Grab tab format from open document + let tabFmt = { + size: editor.options.tabSize as number, + hard: !editor.options.insertSpaces + }; + let i = pl.Lexer.getIndent(textLine.text, tabFmt); vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Indentation " + i.toString()); } }