From abb6056311a24db82aa1392f17059774e37de5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 11 Oct 2021 10:22:11 +0200 Subject: [PATCH 1/4] Update monaco-editor-core --- example/package.json | 2 +- package.json | 2 +- yarn.lock | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/example/package.json b/example/package.json index 56e35a819..2e50ceef5 100644 --- a/example/package.json +++ b/example/package.json @@ -6,7 +6,7 @@ "@codingame/monaco-jsonrpc": "^0.3.1", "express": "^4.15.2", "file-loader": "^4.3.0", - "monaco-editor-core": "^0.22.3", + "monaco-editor-core": "^0.29.0", "@codingame/monaco-languageclient": "^0.14.0", "normalize-url": "^2.0.1", "reconnecting-websocket": "^3.2.2", diff --git a/package.json b/package.json index 52251fcd4..8b09d5dee 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@types/vscode": "1.52.0", "css-loader": "^0.28.11", "lerna": "^3.16.4", - "monaco-editor-core": "^0.22.3", + "monaco-editor-core": "^0.29.0", "rimraf": "^2.6.2", "source-map-loader": "^0.2.3", "style-loader": "^0.20.3", diff --git a/yarn.lock b/yarn.lock index 8d1b4f66f..1ad76a0ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,6 +30,17 @@ dependencies: vscode-jsonrpc "^6.0.0" +"@codingame/monaco-languageclient@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@codingame/monaco-languageclient/-/monaco-languageclient-0.14.0.tgz#d5cf712e5ee58159ec443f821503dbf8287badb8" + integrity sha512-4KBN/GmfXqALSORrCC6O1gKPpRHvA1pi2Psma/VniG1vPpAsUHQunfL1mGOw3OWd9W1v1yRZzt+wnHB1P14UuA== + dependencies: + glob-to-regexp "^0.4.1" + vscode-jsonrpc "6.0.0" + vscode-languageclient "7.0.0" + vscode-languageserver-textdocument "^1.0.1" + vscode-uri "^3.0.2" + "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" @@ -4776,10 +4787,10 @@ modify-values@^1.0.0: resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== -monaco-editor-core@^0.22.3: - version "0.22.3" - resolved "https://registry.yarnpkg.com/monaco-editor-core/-/monaco-editor-core-0.22.3.tgz#decb2d53d4c87f1d838c4a78e27570f9aca2ecbd" - integrity sha512-QUA8fbVz769QBR5Xp8vKJngJM35PRvMuqDjVSsM5IJfWwwVEsQAKu/8SUD3jcEHfnE4YgQfeLktapBwJvWntgw== +monaco-editor-core@^0.29.0: + version "0.29.1" + resolved "https://registry.yarnpkg.com/monaco-editor-core/-/monaco-editor-core-0.29.1.tgz#187bd48b4c0eef7dd4c60e012ad5df4823cfdc74" + integrity sha512-A2+iNWf2Jhy/yAJ8HaDIszEhAlS1xjLvQfbk41yAyGwC4wDwbcTymUud1g0I9nV31S1x7QlXNC0BABc2uZN1Qg== move-concurrently@^1.0.1: version "1.0.1" From 87d2ed829ab25095380e0adcb5f0a02bd4898397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 11 Oct 2021 10:28:50 +0200 Subject: [PATCH 2/4] Properly implement code action resolver --- client/src/monaco-languages.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/client/src/monaco-languages.ts b/client/src/monaco-languages.ts index 6f7d7bd8f..8ae54aa87 100644 --- a/client/src/monaco-languages.ts +++ b/client/src/monaco-languages.ts @@ -11,7 +11,7 @@ import { OnTypeFormattingEditProvider, RenameProvider, DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider, FoldingRangeProvider, SemanticTokensLegend, - DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, Command + DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider } from "./services"; import { MonacoDiagnosticCollection } from './monaco-diagnostic-collection'; @@ -248,25 +248,17 @@ export class MonacoLanguages implements Languages { } const params = this.m2p.asCodeActionParams(model, range, context); let result = await provider.provideCodeActions(params, token); - - // FIXME: get rid of it and implement resolveCodeAction when https://github.com/microsoft/monaco-editor/issues/2663 is resolved + return result && this.p2m.asCodeActionList(result); + }, + resolveCodeAction: provider.resolveCodeAction ? async (codeAction, token) => { + const params = this.m2p.asCodeAction(codeAction); + const result = await provider.resolveCodeAction!(params, token); if (result) { - if (provider.resolveCodeAction) { - result = await Promise.all(result.map(async item => { - if (!Command.is(item) && !item.edit) { - const resolved = await provider.resolveCodeAction!(item, token) - if (resolved) { - return resolved - } - } - return item - })) - } - - return this.p2m.asCodeActionList(result) + const resolvedCodeAction = this.p2m.asCodeAction(result); + Object.assign(codeAction, resolvedCodeAction); } - return undefined - } + return codeAction; + } : undefined } } From 1ac64d55048a89a6c877c967e502219cf995a66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 11 Oct 2021 10:29:51 +0200 Subject: [PATCH 3/4] resolveCodeLens accept undefined --- client/src/monaco-languages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/monaco-languages.ts b/client/src/monaco-languages.ts index 8ae54aa87..e63f25971 100644 --- a/client/src/monaco-languages.ts +++ b/client/src/monaco-languages.ts @@ -292,7 +292,7 @@ export class MonacoLanguages implements Languages { Object.assign(codeLens, resolvedCodeLens); } return codeLens; - } : ((_, codeLens) => codeLens) + } : undefined } } From f85fe90d3e1ed2e5cc441d20a829e2b86551f994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 11 Oct 2021 10:47:41 +0200 Subject: [PATCH 4/4] Check on Command instead of CodeAction CodeAction.is would return false if there is no edit field --- client/src/monaco-converter.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/client/src/monaco-converter.ts b/client/src/monaco-converter.ts index 0a4236dd9..f2659b88e 100644 --- a/client/src/monaco-converter.ts +++ b/client/src/monaco-converter.ts @@ -639,25 +639,25 @@ export class ProtocolToMonacoConverter { } asCodeAction(item: Command | CodeAction): ProtocolCodeAction { - if (CodeAction.is(item)) { + if (Command.is(item)) { return { - title: item.title, - command: this.asCommand(item.command), - edit: this.asWorkspaceEdit(item.edit), - diagnostics: this.asDiagnostics(item.diagnostics), - kind: item.kind, - disabled: item.disabled ? item.disabled.reason : undefined, - isPreferred: item.isPreferred, - data: item.data + command: { + id: item.command, + title: item.title, + arguments: item.arguments + }, + title: item.title }; } return { - command: { - id: item.command, - title: item.title, - arguments: item.arguments - }, - title: item.title + title: item.title, + command: this.asCommand(item.command), + edit: this.asWorkspaceEdit(item.edit), + diagnostics: this.asDiagnostics(item.diagnostics), + kind: item.kind, + disabled: item.disabled ? item.disabled.reason : undefined, + isPreferred: item.isPreferred, + data: item.data }; }