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

Add #97640: Added options to enable codelens for diff editors #97644

Merged
merged 5 commits into from
Jul 10, 2020

Conversation

ludokx
Copy link
Contributor

@ludokx ludokx commented May 12, 2020

This PR fixes #97640.

Description

This PR adds new options originalCodeLens and modifiedCodeLens to enable CodeLens in the original/modified diff editors (hard coded to false before this PR).

How to Test

As described in the monaco-editor documentation, vscode and monaco-editor must be siblings.

Once vscode is built with yarn watchd, go into monaco-editor, run npm run build-website and then npm run simpleserver.

Pick an HTML file under test/playground.generated/ and change to the source below, then open in the browser. I modified extending-language-services-codelens-provider-example.html.

var originalModel = monaco.editor.createModel("just some text\n\nHello World\n\nSome more text", "plaintext");
var modifiedModel = monaco.editor.createModel("just some Text\n\nHello World\n\nSome more changes", "plaintext");

var editor = monaco.editor.createDiffEditor(document.getElementById("container"), { modifiedCodeLens: true });
editor.setModel({
	original: originalModel,
    modified: modifiedModel,
});

var commandId = editor.addCommand(0, function () {
    alert('code lens is working!');
}, '');

monaco.languages.registerCodeLensProvider('plaintext', {
    provideCodeLenses: function (model, token) {
        return {
            lenses: [
                {
                    range: {
                        startLineNumber: 1,
                        startColumn: 1,
                        endLineNumber: 2,
                        endColumn: 1
                    },
                    id: "First Line",
                    command: {
                        id: commandId,
                        title: "First Line"
                    }
                }
            ]
        };
    },
    resolveCodeLens: function (model, codeLens, token) {
        return codeLens;
    }
});

Open your browser at:
http://127.0.0.1:8080/monaco-editor/test/playground.generated/extending-language-services-codelens-provider-example.html?editor=src

For editor on the right-hand side, select src to run the code you build from vscode.

The code lens shows up in the first line of the modified editor.

@msftclas
Copy link

msftclas commented May 12, 2020

CLA assistant check
All CLA requirements met.

@alexdima
Copy link
Member

@ludokx Please sign the Contributor License Agreement, so I can take a look at this -- see the above comment

@ludokx
Copy link
Contributor Author

ludokx commented May 14, 2020

@alexdima done, sorry needed to clarify some things first. What about the VS Code pipeline failure though, seems to be something intermittent and unrelated. How can it be re-run?

@ludokx
Copy link
Contributor Author

ludokx commented May 29, 2020

@alexdima quick follow to see if there's anything I can do to get the VS Code check to pass?

*/
originalCodeLens?: boolean;
/**
* Original editor should be have code lens enabled?

Choose a reason for hiding this comment

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

typo: should be "Modified editor" here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, copy/paste... :/ good catch, thanks!

Choose a reason for hiding this comment

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

no problem

*/
originalCodeLens?: boolean;
/**
* Original editor should be have code lens enabled?

Choose a reason for hiding this comment

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

same as below

@ludokx
Copy link
Contributor Author

ludokx commented Jun 2, 2020

@MehaKaushik thank for catching those typos. The VS Code pipeline failed again but I don't see how this could be related to my change, the default values should have no impact on prior behavior at all. Is there a way to kick off the pipeline again without creating a new commit?

@MehaKaushik
Copy link

@MehaKaushik thank for catching those typos. The VS Code pipeline failed again but I don't see how this could be related to my change, the default values should have no impact on prior behavior at all. Is there a way to kick off the pipeline again without creating a new commit?

I believe anyone with write permissions on this repo would be able to run the pipelines for you.

@ludokx
Copy link
Contributor Author

ludokx commented Jun 25, 2020

@alexdima @MehaKaushik anything else I should do for this PR? Thanks

@alexdima
Copy link
Member

Thank you!

@alexdima alexdima added this to the July 2020 milestone Jul 10, 2020
@alexdima alexdima merged commit 9ada582 into microsoft:master Jul 10, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CodeLens in diff editor
4 participants