Skip to content

Commit be28ebf

Browse files
committed
Call LSP command as fallback for switch header/source action
1 parent e8f572a commit be28ebf

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/commands/switchHeaderSource.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { getMatchingHeaderSource, logger } from '../extension';
2+
import { getMatchingHeaderSource, logger, activeLanguageServer, LanguageServer } from '../extension';
33

44

55
export async function switchHeaderSourceInWorkspace(): Promise<boolean | undefined> {
@@ -11,8 +11,16 @@ export async function switchHeaderSourceInWorkspace(): Promise<boolean | undefin
1111

1212
const matchingUri = await getMatchingHeaderSource(editor.document.uri);
1313
if (!matchingUri) {
14-
logger.alertInformation('No matching header/source file was found.');
15-
return;
14+
if (activeLanguageServer() == LanguageServer.cpptools)
15+
vscode.commands.executeCommand('C_Cpp.SwitchHeaderSource');
16+
else if (activeLanguageServer() == LanguageServer.clangd)
17+
vscode.commands.executeCommand('clangd.switchheadersource');
18+
else {
19+
logger.alertInformation('No matching header/source file was found.');
20+
return false;
21+
}
22+
logger.logInfo('No matching header/source file was found.');
23+
return true;
1624
}
1725

1826
await vscode.window.showTextDocument(matchingUri);

0 commit comments

Comments
 (0)