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

Push indents to after comments #4239

Merged
merged 8 commits into from
Jan 7, 2023
Merged

Push indents to after comments #4239

merged 8 commits into from
Jan 7, 2023

Conversation

alanmcruickshank
Copy link
Member

@alanmcruickshank alanmcruickshank commented Jan 3, 2023

This resolves #4223 . This fix is a little unorthodox - but it works.

When assessing the position of indent effects, we push the effects of any Indent or Dedent segments to after any comment segments. Within a line it shouldn't make a difference, but for end of line comments, it makes sure that any tokens are available in the same IndentPoint that forms the start of the next line. That's the main purpose of what we're doing.

I considered actually moving the Indent and Dedent tokens in the lexing or parsing stage, but that felt like too much "hacking". Keeping this logic in the reflow interpretation code feels acceptable.

@coveralls
Copy link

coveralls commented Jan 4, 2023

Pull Request Test Coverage Report for Build 3859330151

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 3859319340: 0.0%
Covered Lines: 16918
Relevant Lines: 16918

💛 - Coveralls

@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (838cae7) compared to base (665e2a2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #4239   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          200       200           
  Lines        15143     15148    +5     
=========================================
+ Hits         15143     15148    +5     
Impacted Files Coverage Δ
src/sqlfluff/utils/reflow/reindent.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alanmcruickshank alanmcruickshank marked this pull request as ready for review January 6, 2023 21:44
test_fail_coverage_indent_trough:
# This test primarily tests the handling of closing trough indents
fail_str: |
WITH bar as (SELECT 1
Copy link
Member

Choose a reason for hiding this comment

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

In the past, L003 only handled indentation. Any concerns that here it is moving code between lines?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so - this is functionality that is already out in the wild in the treatment of existing hanging indents in 2.0.0a1. All this PR does is fix a bug with it.

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.

2.0.0a1 - Comments cause inconsistent indentation of CASE
3 participants