1
1
import * as vscode from 'vscode'
2
2
import * as monaco from 'monaco-editor'
3
+ import { Middleware } from 'monaco-languageclient'
3
4
import type { LanguageClientOptions } from './languageClientOptions'
4
5
5
6
type LanguageClientOptionsById < T extends string > = Record < T , LanguageClientOptions >
6
7
const asLanguageClientOptionsById = < K extends string > ( options : LanguageClientOptionsById < K > ) : LanguageClientOptionsById < K > => options
7
8
9
+ const clangdHotfixMiddleware : Middleware = {
10
+ async provideCompletionItem ( document , position , context , token , next ) {
11
+ const list = await next ( document , position , context , token )
12
+ // Hotfix (see https://github.com/clangd/vscode-clangd/blob/df56a9a058fca773eb4c096d0f6a5a31b71b79d7/src/clangd-context.ts#L124)
13
+ const items = Array . isArray ( list ) ? list : list ?. items
14
+ if ( items != null ) {
15
+ for ( const item of items ) {
16
+ item . commitCharacters = [ ]
17
+ }
18
+ }
19
+ return list
20
+ }
21
+ }
22
+
8
23
const staticOptions = asLanguageClientOptionsById ( {
9
24
angular : {
10
25
documentSelector : [
@@ -31,6 +46,7 @@ const staticOptions = asLanguageClientOptionsById({
31
46
{ scheme : 'file' , language : 'c' } ,
32
47
{ scheme : 'file' , language : 'cpp' }
33
48
] ,
49
+ middleware : clangdHotfixMiddleware ,
34
50
mutualizable : false
35
51
// The extension is cpptools BUT the language server is unable to use the client configuration (it requires client code)
36
52
// vscodeExtensionIds: ['cpptools']
@@ -71,6 +87,7 @@ const staticOptions = asLanguageClientOptionsById({
71
87
{ scheme : 'file' , language : 'cpp' } ,
72
88
{ scheme : 'file' , language : 'cuda-cpp' }
73
89
] ,
90
+ middleware : clangdHotfixMiddleware ,
74
91
mutualizable : false
75
92
// The extension is cpptools BUT the language server is unable to use the client configuration (it requires client code)
76
93
// vscodeExtensionIds: ['cpptools']
@@ -221,6 +238,7 @@ const staticOptions = asLanguageClientOptionsById({
221
238
{ scheme : 'file' , language : 'cpp' } ,
222
239
{ scheme : 'file' , language : 'objective-c' }
223
240
] ,
241
+ middleware : clangdHotfixMiddleware ,
224
242
mutualizable : false
225
243
// The extension is cpptools BUT the language server is unable to use the client configuration (it requires client code)
226
244
// vscodeExtensionIds: ['cpptools']
0 commit comments