Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkenefick committed Feb 21, 2022
1 parent 35cdb60 commit ee8d110
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/functions/insertBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function insertBox(lineLength: number = 80): Promise<void> {

// Remove selection (next tick)
setTimeout(() => {
const position: vscode.Position = new vscode.Position(selection.end.line + 3, 0);
const position: vscode.Position = new vscode.Position((selection?.end?.line || 0) + 3, 0);
editor.selection = new vscode.Selection(position, position);
}, 1);
}
10 changes: 5 additions & 5 deletions src/functions/isWithinBox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import constants from '../constants';
import Constants from '../constants';

/**
* Figure out if we're inside an existing box already
Expand All @@ -9,7 +9,7 @@ import constants from '../constants';
* @return boolean
*/
export function isWithinBox(removeComments: boolean = true, lineNumber: number = -1): boolean {
const editor: vscode.TextEditor = vscode.window.activeTextEditor;
const editor = vscode.window.activeTextEditor;
const document: vscode.TextDocument | undefined = editor?.document;
const selection: vscode.Selection | undefined = editor?.selection;

Expand All @@ -30,8 +30,8 @@ export function isWithinBox(removeComments: boolean = true, lineNumber: number =
}

return (
line.charAt(0) === constants.CHAR_TL
|| line.charAt(0) === constants.CHAR_L
|| line.charAt(0) === constants.CHAR_BL
line.charAt(0) === Constants.CHAR_TL
|| line.charAt(0) === Constants.CHAR_L
|| line.charAt(0) === Constants.CHAR_BL
);
}
2 changes: 1 addition & 1 deletion src/functions/parseLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function parseLines(selection: vscode.Selection, maxLineLength: number =
// Process each line
masterArray.forEach((line: string, index: number) => {
if (line.trim() === '--') {
masterArray[index] = CHAR_DM.repeat(maxLineLength - 2); // - 2 because we remove the spaces
masterArray[index] = Constants.CHAR_DM.repeat(maxLineLength - 2); // - 2 because we remove the spaces
}
else {
masterArray[index] = line + ' '.repeat(Math.max(0, maxLineLength - line.length - 4));
Expand Down

0 comments on commit ee8d110

Please sign in to comment.