Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State that the WorkspaceClientCapabilites's applyEdit capability is enabled #55

Merged
merged 1 commit into from
Feb 12, 2018

Conversation

rcjsuen
Copy link
Collaborator

@rcjsuen rcjsuen commented Feb 11, 2018

In #21 support for the workspace/applyEdit request was added so the client should state this fact in its WorkspaceClientCapabilites.

My language server will only provide code actions if the client supports workspace/applyEdit requests so I need this to be enabled correctly so that my language server will work with this editor.

import { WorkspaceEdit } from 'vscode-base-languageclient/lib/base';
import IModel = monaco.editor.IModel;
import IResourceEdit = monaco.languages.IResourceEdit;

export class MonacoWorkspace implements Workspace {

public readonly capabilities: WorkspaceClientCapabilites = {
applyEdit: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch! I think documentChanges are covered by applyEdit as well. Could you add them to capabilities please:

    applyEdit: true,
    workspaceEdit: {
        documentChanges: true
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akosyakov Actually, the documentChanges support isn't perfect right now.

if (item.documentChanges) {
for (const change of item.documentChanges) {
const resource = monaco.Uri.parse(change.textDocument.uri);
edits.push(...this.asResourceEdits(resource, change.edits));
}
} else if (item.changes) {

We just convert them into IResourceEdits without checking if the version from the language server matches what's in the Monaco Editor. I am planning to address this (as well as updating the capabilities) in a separate pull request.

Copy link
Contributor

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Pull request TypeFox#21 added support for the workspace/applyEdit capability
so it should be stated as such in the WorkspaceClientCapabilities.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants