-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix #4305 by coping with replacement request with start == line after the last #4311
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #4311 +/- ##
===========================================
- Coverage 89.88% 75.31% -14.57%
===========================================
Files 37 30 -7
Lines 4763 2901 -1862
===========================================
- Hits 4281 2185 -2096
- Misses 482 716 +234 🚀 New features to boost your workflow:
|
|
Seems similar to a bug i have fixed in my fork, but wasn't completely happy with. The issue is when the edit is right at the end of the buffer, correct? I think this is what I tried. is your version better? thoughts? |
I'd say right past the end, but yeah. |
I don't like that Incidentally, are you against stating preconditions? What's the way of doing it in Python? I'm referring to the fact that if start_line == len( vim_buffer ):
start_line = len( vim_buffer ) - 1
replacement_lines = [ ToBytes( vim_buffer[ -1 ] ) ] + replacement_linesand then put something like if start_line > len( vim_buffer ):
raise SomeError()right after the definition |
|
@puremourning , are those test failures relevant? |
PR Prelude
Thank you for working on YCM! :)
Please complete these steps and check these boxes (by putting an
xinsidethe brackets) before filing your PR:
rationale for why I haven't.
actually perform all of these steps.
Why this change is necessary and useful
My understanding, from what reported in #4305 and what I've experienced, is that the existing code was not written with the idea that a
ReplaceChunkcould be fed with astartthat is the line after the last line of the buffer, i.e. when it is== len( vim_buffer )(I don't think a request can be made with a number higher than that, e.g. "insert from line 9 in a 7-lines file").This change copes with that case by setting
start_lineback to the last line index (I've donestart_line -= 1, but maybestart_line = len( vim_buffer )would be better?), and prepending the last line to thereplacement_linesas originally compmuted.The test I've written passes, and the usecase I've described and screencasted in #4305 is fixed.
[Please explain in detail why the changes in this PR are needed.]
This change is