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

Checking that the effectiveLineNumber is valid before accessing the line content #200051

Merged
merged 7 commits into from
Dec 12, 2023

Conversation

aiday-mar
Copy link
Contributor

Fixes #199938

@aiday-mar aiday-mar self-assigned this Dec 5, 2023
@aiday-mar aiday-mar marked this pull request as ready for review December 5, 2023 15:17
@aeschli
Copy link
Contributor

aeschli commented Dec 6, 2023

The problem is on line 205, where the effectiveLineNumber is increased without checking whether this is possible.

@aiday-mar
Copy link
Contributor Author

Integration test errors appear to not be related at all to the change, this is quite curious, this needs some investigation

@aiday-mar aiday-mar marked this pull request as draft December 6, 2023 13:17
aeschli
aeschli previously approved these changes Dec 6, 2023
@aiday-mar aiday-mar marked this pull request as ready for review December 6, 2023 14:49
@aiday-mar
Copy link
Contributor Author

aiday-mar commented Dec 8, 2023

Yesterday during our discussion you mentioned that we could reuse the calculation in the variable lineHasSpace to calculate the effective column number. After some inspection I am not sure this would make the code clearer. The current effective column number is calculated as follows:

!!model.getLineContent(effectiveLineNumber).match(/^\S\s*$/) ? 2 : 1

So the effective column number is:

  • 2 is there is only one character at the beginning of the line, and the rest are whitespace
  • 1 otherwise

I am not sure how the lineHasSpace calculation would be used here? Initially that column value was 1 before the recent lightbulb work done.

@aeschli
Copy link
Contributor

aeschli commented Dec 8, 2023

ok. sure. Buyt still, the check to go on column 2 should only happen if we increased or decreased the effective line number.

@aeschli
Copy link
Contributor

aeschli commented Dec 8, 2023

ok. sure. But still, the check and column update should only happen when there was no space on the original line.

@aiday-mar
Copy link
Contributor Author

Ah yes now I understand, will do 👍🏻

@aiday-mar
Copy link
Contributor Author

I added the code into the if statement

@alexdima alexdima requested review from justschen and removed request for aeschli December 12, 2023 13:58
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

LGTM. @justschen Please also take a look.

Copy link
Contributor

@justschen justschen left a comment

Choose a reason for hiding this comment

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

yes lgtm!

@aiday-mar aiday-mar merged commit 7bf0f1c into main Dec 12, 2023
6 checks passed
@aiday-mar aiday-mar deleted the aiday/checkingEffectiveLineCount branch December 12, 2023 16:25
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Illegal value for lineNumber
4 participants