Skip to content

Commit f4edadf

Browse files
committed
_update_command: Fix bug when checking type of action.region
1 parent c59bb6f commit f4edadf

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

src/cedarscript_editor/cedarscript_editor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _update_command(self, cmd: UpdateCommand):
133133
# ''';
134134
# target = IdentifierFromFile(file_path='refactor-benchmark/checks_BaseModelAdminChecks__check_raw_id_fields_item/checks.py', identifier_type=<MarkerType.FUNCTION: 'function'>, name='_check_raw_id_fields_item', where_clause=None, offset=None)
135135
# action = ReplaceClause(region=Marker(type=<MarkerType.LINE: line>, value=def _check_raw_id_fields_item(self, obj, field_name, label):, offset=None))
136-
if search_range.line_count and not isinstance(action.region, Segment):
136+
if search_range.line_count and not isinstance(action.region if hasattr(action, 'region') else None, Segment):
137137
marker, search_range = find_marker_or_segment(action, lines, search_range)
138138
search_range = restrict_search_range_for_marker(
139139
marker, action, lines, search_range, identifier_finder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<no-train>
2+
```CEDARScript
3+
UPDATE FILE "main.something"
4+
INSERT BEFORE LINE "parturient"
5+
WITH CONTENT '''
6+
@-4:#@-4 before line 'parturient'
7+
'''
8+
```
9+
</no-train>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Lorem ipsum odor amet,
2+
consectetuer adipiscing elit.
3+
Ligula vestibulum semper sagittis sapien class.
4+
Dolor nascetur litora feugiat urna,
5+
natoque venenatis fames.
6+
At elementum urna suspendisse
7+
himenaeos massa dui.
8+
Vivamus in
9+
risus cursus
10+
ac vulputate dolor;
11+
amet pulvinar.
12+
Fames tempus habitasse
13+
etiam a
14+
#@-4 before line 'parturient'
15+
parturient
16+
mollis.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Lorem ipsum odor amet,
2+
consectetuer adipiscing elit.
3+
Ligula vestibulum semper sagittis sapien class.
4+
Dolor nascetur litora feugiat urna,
5+
natoque venenatis fames.
6+
At elementum urna suspendisse
7+
himenaeos massa dui.
8+
Vivamus in
9+
risus cursus
10+
ac vulputate dolor;
11+
amet pulvinar.
12+
Fames tempus habitasse
13+
etiam a
14+
parturient
15+
mollis.

0 commit comments

Comments
 (0)