mirror of
				https://github.com/We-Dont-Byte/Mind_Reader.git
				synced 2025-02-04 10:38:42 +00:00 
			
		
		
		
	Merge pull request #11 from SingleSemesterSnobs/cal
Merge indentation level and line number hotkey
This commit is contained in:
		
							
								
								
									
										17
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								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": [
 | 
			
		||||
 
 | 
			
		||||
@@ -117,6 +117,10 @@ const commands: Command[] = [
 | 
			
		||||
  {
 | 
			
		||||
    name: 'mind-reader.runCursorContext',
 | 
			
		||||
    callback: runCursorContext
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    name: 'mind-reader.getIndent',
 | 
			
		||||
    callback: getIndent
 | 
			
		||||
  }
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
@@ -146,9 +150,36 @@ function resetEditorScale(): void {
 | 
			
		||||
  vscode.commands.executeCommand('workbench.action.zoomReset');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getIndent(): void {
 | 
			
		||||
  let editor = vscode.window.activeTextEditor;
 | 
			
		||||
  if(editor)
 | 
			
		||||
  {
 | 
			
		||||
    let lineNum = editor.selection.active.line + 1;
 | 
			
		||||
    let textLine = editor.document.lineAt(lineNum - 1);
 | 
			
		||||
    if(textLine.isEmptyOrWhitespace)
 | 
			
		||||
    {
 | 
			
		||||
      vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      // 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());
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else{
 | 
			
		||||
    vscode.window.showErrorMessage('No document currently active');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user