File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1689,6 +1689,7 @@ std::vector<CodeAction> GenerateAutoExpandCodeActions(
1689
1689
const BufferTracker *const tracker, const CodeActionParams &p) {
1690
1690
Interval<size_t > line_range{static_cast <size_t >(p.range .start .line ),
1691
1691
static_cast <size_t >(p.range .end .line )};
1692
+ if (!line_range.valid ()) return {};
1692
1693
if (!tracker) return {};
1693
1694
const auto current = tracker->current ();
1694
1695
if (!current) return {}; // Can only expand if we have latest version
Original file line number Diff line number Diff line change @@ -3600,6 +3600,43 @@ endmodule
3600
3600
);
3601
3601
}
3602
3602
3603
+ TEST (Autoexpand, InvalidLineRange) {
3604
+ TestTextEdits (
3605
+ R"(
3606
+ module foo ( /*AUTOARG*/);
3607
+ /*AUTOINPUT*/
3608
+ /*AUTOOUTPUT*/
3609
+
3610
+ /* qux AUTO_TEMPLATE
3611
+ bar AUTO_TEMPLATE (
3612
+ .o1(out_a[]),
3613
+ .o2(out_b[])
3614
+ ); */
3615
+ bar b ( /*AUTOINST*/);
3616
+ endmodule
3617
+ )" ,
3618
+ R"(
3619
+ module foo ( /*AUTOARG*/);
3620
+ /*AUTOINPUT*/
3621
+ /*AUTOOUTPUT*/
3622
+
3623
+ /* qux AUTO_TEMPLATE
3624
+ bar AUTO_TEMPLATE (
3625
+ .o1(out_a[]),
3626
+ .o2(out_b[])
3627
+ ); */
3628
+ bar b ( /*AUTOINST*/);
3629
+ endmodule
3630
+ )" ,
3631
+ TestRun{.edit_fn = [](SymbolTableHandler *symbol_table_handler,
3632
+ BufferTracker *tracker) {
3633
+ return AutoExpandCodeActionToTextEdits (
3634
+ symbol_table_handler, tracker,
3635
+ {.start = {.line = 5 }, .end = {.line = 1 }},
3636
+ " Expand with invalid range" );
3637
+ }}.repeat ());
3638
+ }
3639
+
3603
3640
TEST (Autoexpand, InstanceNotModule) {
3604
3641
TestTextEdits (
3605
3642
R"(
You can’t perform that action at this time.
0 commit comments