rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Fix selection end column if pruning an empty last column #6184

Closed tommy9 closed 10 months ago

tommy9 commented 10 months ago

Fixes #6181

When a selection of code includes a trailing blank line, the GetSelection method cuts this line and sets the end column to the length of the previous line. However, selections are supposed to be one-based, so we want the length plus 1. E.g. if selecting a line which is just End, we should see start column = 1, end column = 4 which we do if that is the only line selected but if changing the selection to include an extra blank line, the selection gets modified to have end column = 3.

I'm not sure exactly why the last blank line if being pruned but it's not relevant to this issue. Note that only one blank line would be pruned even if there are multiple.

rubberduck-vba-releasebot commented 10 months ago

:white_check_mark: Build Rubberduck 2.5.9.6311 completed (commit https://github.com/rubberduck-vba/Rubberduck/commit/957fc299d3 by @tommy9)

codecov[bot] commented 10 months ago

Codecov Report

Merging #6184 (ce21fbf) into next (9323f70) will increase coverage by 0.24%. The diff coverage is n/a.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## next #6184 +/- ## ========================================== + Coverage 97.34% 97.58% +0.24% ========================================== Files 4 4 Lines 413 413 Branches 28 28 ========================================== + Hits 402 403 +1 Misses 6 6 + Partials 5 4 -1 ``` [see 1 file with indirect coverage changes](https://app.codecov.io/gh/rubberduck-vba/Rubberduck/pull/6184/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rubberduck-vba)