Skip to content

Commit

Permalink
handles empty selections
Browse files Browse the repository at this point in the history
  • Loading branch information
amitjoshi committed Sep 29, 2023
1 parent fbc324b commit d9bef02
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ export function getSelectedCode(editor: vscode.TextEditor): string {
}
const selection = editor.selection;
const text = editor.document.getText(selection);
return text;
return text.trim(); //handles empty selection
}

/**
* Returns the start and end line numbers of the selected code in the editor.
* @param editor The vscode TextEditor object.
* @returns An object with start and end line numbers.
*/
export function getSelectedCodeLineRange(editor: vscode.TextEditor): { start: number, end: number } {
if (!editor) {
return { start: 0, end: 0 };
Expand Down

0 comments on commit d9bef02

Please sign in to comment.