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

vscode: add syntax tree inspection hovers and highlights #3787

Merged
merged 6 commits into from
Mar 31, 2020

Conversation

Veetaha
Copy link
Contributor

@Veetaha Veetaha commented Mar 31, 2020

inspect-tree
I implemented the reverse mapping (when you hover in the rust editor), but it seems overcomplicated, so I removed it

Related #3682

@Veetaha Veetaha force-pushed the feature/complete-extern-fns branch 2 times, most recently from a181e28 to 065545e Compare March 31, 2020 13:15
class TextDocumentContentProvider implements vscode.TextDocumentContentProvider, Disposable {
readonly uri = vscode.Uri.parse('rust-analyzer://syntaxtree');
readonly eventEmitter = new vscode.EventEmitter<vscode.Uri>();
private readonly disposables: Disposable[] = [];
Copy link
Member

@matklad matklad Mar 31, 2020

Choose a reason for hiding this comment

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

tdcp is a singleton, so we can just re-use ctx.subscriptions without implementing our our disposing logic.

@Veetaha Veetaha force-pushed the feature/complete-extern-fns branch from 065545e to 09a760e Compare March 31, 2020 13:21
border: "#ffffff 1px solid",
});
private rustEditor: undefined | RustEditor;
private readonly disposables: Disposable[] = [];
Copy link
Member

Choose a reason for hiding this comment

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

same here, there's only ever one of these, so it doesn't need its own disposable array.

@Veetaha
Copy link
Contributor Author

Veetaha commented Mar 31, 2020

@matklad
Shouldn't we use the unifrom disposables array for handles? Using ctx.subscriptions is the straightforward, but seems to be the wrong way...

@matklad
Copy link
Member

matklad commented Mar 31, 2020 via email

@Veetaha
Copy link
Contributor Author

Veetaha commented Mar 31, 2020

Migrated to the existing thing, added docs.
Also, I should note on a caveat. This works only when you have a single rust file editor visible, otherwise, it may highlight the wrong file, but I don't this will be an issue since this is just a debugging convenience.

@Veetaha
Copy link
Contributor Author

Veetaha commented Mar 31, 2020

Added revealRange() to automatically scroll the viewport to the highlighted rust source code bit:
f3612b7

@matklad
Copy link
Member

matklad commented Mar 31, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 31, 2020

@bors bors bot merged commit f77fc15 into rust-lang:master Mar 31, 2020
@lnicola
Copy link
Member

lnicola commented Apr 1, 2020

This doesn't play nice with light themes 😅. I was wondering why I don't see the border.

@Veetaha
Copy link
Contributor Author

Veetaha commented Apr 1, 2020

ggwp

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.

None yet

3 participants