mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
70bc432f85
Because our snippet generator is trying to select whole lines to include in the snippet, it has some edge cases for odd situations where the relevant source range starts or ends directly at a newline, which were previously causing this logic to return out-of-bounds offsets into the code snippet string. Although arguably it'd be better for the original diagnostics to report more reasonable source ranges, it's better for us to report a slightly-inaccurate snippet than to crash altogether, and so we'll extend our existing range checks to check both bounds of the string and thus avoid downstreams having to deal with out-of-bounds indices. For completeness here I also added some similar logic to the human-oriented diagnostic formatter, which consumes the result of the JSON diagnostic builder. That's not really needed with the additional checks in the JSON diagnostic builder, but it's nice to reinforce that this code can't panic (in this way, at least) even if its input isn't valid. |
||
---|---|---|
.. | ||
json | ||
add_test.go | ||
add.go | ||
apply_test.go | ||
apply.go | ||
hook_count_test.go | ||
hook_count.go | ||
hook_json_test.go | ||
hook_json.go | ||
hook_ui_test.go | ||
hook_ui.go | ||
json_view_test.go | ||
json_view.go | ||
operation_test.go | ||
operation.go | ||
output_test.go | ||
output.go | ||
plan_test.go | ||
plan.go | ||
refresh_test.go | ||
refresh.go | ||
show.go | ||
state_locker.go | ||
test_test.go | ||
test.go | ||
validate_test.go | ||
validate.go | ||
view.go |