-
Notifications
You must be signed in to change notification settings - Fork 466
[Discussion] [Live Share] Restricting language services on file scheme #492
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
Conversation
Signed-off-by: Jonathan Carter <[email protected]>
src/extension.ts
Outdated
documentSelector: ['java'], | ||
documentSelector: [ | ||
{ scheme: 'file', language: 'java' }, | ||
{ scheme: 'untitled', language: 'java' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need
{ scheme: 'jdt', language: 'java' },
else we lose all the java support (hover, navigation...) when opening sources (try ctrl+click on String)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Just fixed this.
@lostintangent your "Visual Studio Live Share" link is dead, do you have a better one? |
Signed-off-by: Jonathan Carter <[email protected]>
@fbricon Apologies! I forgot to add the |
src/extension.ts
Outdated
@@ -82,6 +85,7 @@ export function activate(context: ExtensionContext) { | |||
let languageClient = new LanguageClient('java', 'Language Support for Java', serverOptions, clientOptions); | |||
languageClient.registerProposedFeatures(); | |||
languageClient.onReady().then(() => { | |||
toggleItem(window.activeTextEditor, item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too comfortable moving the toggleItem call here. It's currently displayed as soon as the extension starts, regardless of the server state. Now, if there's an error, it won't be displayed, so you won't be able to open the server output log from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll revert this change, as it isn't critical to the main intent of this PR.
Signed-off-by: Jonathan Carter <[email protected]>
Signed-off-by: Jonathan Carter <[email protected]>
@lostintangent thanks for the patch! |
In preparation for Visual Studio Live Share adding support for "guests" to receive remote language services for Java, this PR simply updates the current
DocumentSelector
to be limited tofile
anduntitled
(unsaved) files. This way, when someone has this extension installed, and joins a Live Share session (where files use thevsls:
scheme), their language services will be entirely derived from the remote/host side, which provides a more accurate and project-wide experience (guests in Live Share don't have local file access to the project they're collaborating with).If someone joins a Java project using Live Share, and doesn't have this extension installed, then they will automatically receive language services from the host (which is awesome! 🎉), so this PR is simply an optimization for the case where collaborating developers both have the Java extension installed. Additionally, this wouldn't impact the "local" Java development experience.
Note: As an example, the TypeScript/JavaScript language services that come in-box with VS Code already have this scheme restriction, and so this PR replicates that behavior.