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

window/showDocument cannot show two documents because of preview mode #1588

Open
rcjsuen opened this issue Nov 15, 2024 · 3 comments
Open

window/showDocument cannot show two documents because of preview mode #1588

rcjsuen opened this issue Nov 15, 2024 · 3 comments
Labels
info-needed Issue requires more information from poster

Comments

@rcjsuen
Copy link
Contributor

rcjsuen commented Nov 15, 2024

If you have preview mode enabled, window/showDocument cannot be used to open two different documents because the last one will just overlap on top of the first one.

Is this behaviour intentional?

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Nov 18, 2024
@dbaeumer
Copy link
Member

This is something VS Code decides and is not under the control of the LSP VS Code client lib. I am pretty sure that the same happens when using the VS Code API directly. Have you tried this?

@rcjsuen
Copy link
Contributor Author

rcjsuen commented Nov 18, 2024

This is something VS Code decides and is not under the control of the LSP VS Code client lib. I am pretty sure that the same happens when using the VS Code API directly. Have you tried this?

No, I haven't. But yes, I presume it is the same when using the VS Code API directly.

const options: TextDocumentShowOptions = {};
if (params.selection !== undefined) {
options.selection = this.protocol2CodeConverter.asRange(params.selection);
}
if (params.takeFocus === undefined || params.takeFocus === false) {
options.preserveFocus = true;
} else if (params.takeFocus === true) {
options.preserveFocus = false;
}
await Window.showTextDocument(uri, options);

I guess my concern is that overlapping one file over the other seems counter to the intent of the window/showDocument request. I want to implement a "show affected files" action but on VS Code that will not work if the user has previews enabled (which from what I understand is the default setting in VS Code) because it will just keep overlapping the next one on top of the other. If we set preview to false on the TextDocumentShowOptions then the problem goes away.

I could also workaround the problem by using a middleware to intercept the request completely. 🤷

@dbaeumer
Copy link
Member

Actually I don't want to add preview to the spec. This is very specific to editors. I think the best you can do for now is to handle this in the middleware. Is this OK for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants