Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Add selection support for show syntax tree #691

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Jul 12, 2023

Motivation

Server side PR Shopify/ruby-lsp#810

Checking the AST for the entire file is useful, but sometimes the developer might want to know only the AST for a specific selection. This PR makes our command handle the current selection to only display the AST for that part.

Implementation

Selections in VS Code use an anchor (the initial point where the user started dragging) and active (the final point of the selection). If nothing is selected, both still exist, but they have the exact same location.

So, if anchor and active have different positions, it means there's an actual selection and we can instantiate a range and send it as a request parameter.

Note: if the user selects from bottom up, then the positions are inverted (active will happen before anchor). In that case, isReversed is true and we need to account for it when instantiating the range.

@vinistock vinistock added the enhancement New feature or request label Jul 12, 2023
@vinistock vinistock added this to the 2023-Q3 milestone Jul 12, 2023
@vinistock vinistock self-assigned this Jul 12, 2023
@vinistock vinistock requested a review from a team as a code owner July 12, 2023 13:56
@vinistock vinistock requested review from andyw8 and st0012 July 12, 2023 13:56
@vinistock vinistock force-pushed the vs/support_selections_in_show_ast branch from b137bf8 to 9e02b07 Compare July 21, 2023 19:59
Copy link
Contributor

@andyw8 andyw8 left a comment

Choose a reason for hiding this comment

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

Verified against Shopify/ruby-lsp#810

@vinistock vinistock merged commit af0c3b6 into main Jul 24, 2023
5 checks passed
@vinistock vinistock deleted the vs/support_selections_in_show_ast branch July 24, 2023 13:49
andyw8 pushed a commit that referenced this pull request Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants