@@ -27,23 +27,36 @@ export async function activate(context: vscode.ExtensionContext) {
2727 await clangdContext . activate ( context . globalStoragePath , outputChannel ,
2828 context . workspaceState ) ;
2929
30- setInterval ( function ( ) {
31- const cppTools = vscode . extensions . getExtension ( 'ms-vscode.cpptools' ) ;
32- if ( cppTools && cppTools . isActive ) {
33- const cppToolsConfiguration = vscode . workspace . getConfiguration ( 'C_Cpp' ) ;
34- const cppToolsEnabled = cppToolsConfiguration . get ( 'intelliSenseEngine' ) ;
35- if ( cppToolsEnabled !== 'Disabled' ) {
36- vscode . window
37- . showWarningMessage (
38- 'You have both the Microsoft C++ (cpptools) extension and ' +
39- 'clangd extension enabled. The Microsoft IntelliSense features ' +
40- 'conflict with clangd\'s code completion, diagnostics etc.' ,
41- 'Disable IntelliSense' )
42- . then ( _ => {
43- cppToolsConfiguration . update ( 'intelliSenseEngine' , 'Disabled' ,
44- vscode . ConfigurationTarget . Global ) ;
45- } ) ;
30+ const shouldCheck = vscode . workspace . getConfiguration ( 'clangd' ) . get (
31+ 'detectExtensionConflicts' ) ;
32+ if ( shouldCheck ) {
33+ const interval = setInterval ( function ( ) {
34+ const cppTools = vscode . extensions . getExtension ( 'ms-vscode.cpptools' ) ;
35+ if ( cppTools && cppTools . isActive ) {
36+ const cppToolsConfiguration =
37+ vscode . workspace . getConfiguration ( 'C_Cpp' ) ;
38+ const cppToolsEnabled = cppToolsConfiguration . get ( 'intelliSenseEngine' ) ;
39+ if ( cppToolsEnabled !== 'Disabled' ) {
40+ vscode . window
41+ . showWarningMessage (
42+ 'You have both the Microsoft C++ (cpptools) extension and ' +
43+ 'clangd extension enabled. The Microsoft IntelliSense features ' +
44+ 'conflict with clangd\'s code completion, diagnostics etc.' ,
45+ 'Disable IntelliSense' , 'Never show this warning' )
46+ . then ( selection => {
47+ if ( selection == 'Disable IntelliSense' ) {
48+ cppToolsConfiguration . update (
49+ 'intelliSenseEngine' , 'Disabled' ,
50+ vscode . ConfigurationTarget . Global ) ;
51+ } else if ( selection == 'Never show this warning' ) {
52+ vscode . workspace . getConfiguration ( 'clangd' ) . update (
53+ 'detectExtensionConflicts' , false ,
54+ vscode . ConfigurationTarget . Global ) ;
55+ clearInterval ( interval ) ;
56+ }
57+ } ) ;
58+ }
4659 }
47- }
48- } , 5000 ) ;
60+ } , 5000 ) ;
61+ }
4962}
0 commit comments