fix(reflow): use relevant untaken count for indent calculations#2069
Open
dhawkins1234 wants to merge 1 commit intoquarylabs:mainfrom
Open
fix(reflow): use relevant untaken count for indent calculations#2069dhawkins1234 wants to merge 1 commit intoquarylabs:mainfrom
dhawkins1234 wants to merge 1 commit intoquarylabs:mainfrom
Conversation
fab94aa to
5cfd389
Compare
Refactor indentation calculation logic to properly account for indent troughs when determining relevant untaken indents. Previously, the code used `untaken_indents.len()` directly, which didn't filter out irrelevant indents when a trough was present. Changes: - Add `relevant_untaken_count()` method to `IndentPoint` that mirrors the filtering logic in `IndentLine::desired_indent_units()` - Update `lint_line_untaken_positive_indents()` to use the new method - Update `lint_line_untaken_negative_indents()` to use the new method - Add `.max(0)` guards to prevent negative indent values This fixes incorrect indentation calculations in cases where indent troughs are present, ensuring that only relevant untaken indents are considered when computing desired indentation levels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor indentation calculation logic to properly account for indent troughs when determining relevant untaken indents. Previously, the code used
untaken_indents.len()directly, which didn't filter out irrelevant indents when a trough was present. I was getting thread errors and incorrect indentation, especially on larger .sql files, if the spacing_before = align was used, as in the sample configuration[sqruff:layout:type:alias_expression]
spacing_before = align
align_within = select_clause
align_scope = bracketed
oracle_parsed.sql
Changes:
relevant_untaken_count()method toIndentPointthat mirrors the filtering logic inIndentLine::desired_indent_units()lint_line_untaken_positive_indents()to use the new methodlint_line_untaken_negative_indents()to use the new method.max(0)guards to prevent negative indent valuesThis fixes incorrect indentation calculations in cases where indent troughs are present, ensuring that only relevant untaken indents are considered when computing desired indentation levels.