Skip to content

Commit

Permalink
fix: correct async support for openInHorizontalSplit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmu committed Dec 26, 2024
1 parent d356e24 commit 493f5dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/lib/editorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function closePreviewEditor() {
}

// Open the current qp selected item in a horizontal split
export const openInHorizontalSplit = () => {
export const openInHorizontalSplit = async () => {
if (!cx.qp) {
return;
}
Expand All @@ -30,12 +30,11 @@ export const openInHorizontalSplit = () => {
closePreviewEditor();

const { filePath, linePos, colPos } = currentItem.data;
vscode.workspace.openTextDocument(filePath).then((document) => {
vscode.window.showTextDocument(document, options).then((editor) => {
setCursorPosition(editor, linePos, colPos);
cx.qp?.dispose();
});
});
const document = await vscode.workspace.openTextDocument(filePath);
const editor = await vscode.window.showTextDocument(document, options);

if (editor) setCursorPosition(editor, linePos, colPos);
cx.qp?.dispose();
};

// Open the native VSCode search with the provided query and enable regex
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/periscope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ suite('Periscope Core', () => {
const executeCommandStub = sandbox.stub(vscode.commands, 'executeCommand');

// Call search function
await PERISCOPE.search();
PERISCOPE.search();

// Verify QuickPick is shown
assert.strictEqual((mockQuickPick.show as sinon.SinonStub).calledOnce, true, 'Should show QuickPick');
Expand Down

0 comments on commit 493f5dd

Please sign in to comment.