Skip to content
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

Fix illo movement bug #648

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/guiguts/illo_sn_fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_selected_illosn_record(
# Get line number index of the last line of the selected record.
# If not a multi-line record then this will be same index as above.
selected_record_end = selected_record.end.index()
last_line_num = maintext().index(f"{selected_record_end} linestart")
last_line_num = maintext().index(f"{selected_record_end}")
rec = SelectedIlloSNRecord(first_line_num, last_line_num)
return rec

Expand Down Expand Up @@ -300,7 +300,7 @@ def delete_illosn_record_from_file(self, selected: SelectedIlloSNRecord) -> None
prev_line_num = maintext().index(f"{first_line_num}-1l")
prev_line_txt = maintext().get(prev_line_num, f"{prev_line_num} lineend")
# Line after the (last record of the) Illo or SN record.
next_line_num = maintext().index(f"{last_line_num}+1l")
next_line_num = maintext().index(f"{last_line_num}+1l linestart")
next_line_txt = maintext().get(next_line_num, f"{next_line_num} lineend")
# Assume it's a mid-page Illo or SN record unless found otherwise. This is case 3.
if prev_line_txt != "":
Expand Down Expand Up @@ -477,7 +477,7 @@ def move_selection_up(self, tag_type: str) -> None:
# Copy the lines of the Illo or SN record to be moved. Don't include the
# prefixing "*" if present.
the_selected_record_lines = maintext().get(
first_line_num, f"{last_line_num} lineend"
first_line_num, f"{last_line_num}"
)
if the_selected_record_lines[0:1] == "*":
the_selected_record_lines = the_selected_record_lines[1:]
Expand Down Expand Up @@ -522,7 +522,7 @@ def move_selection_down(self, tag_type: str) -> None:
# Look for a suitable blank line. Start at line immediately below the (last line of
# the) selected Illo or SN record. NB We may not be able to move the record at all if
# it means skipping over another tag of the same type.
line_num = maintext().index(f"{last_line_num}+1l")
line_num = maintext().index(f"{last_line_num}+1l linestart")
# Set end of loop criteria.
file_end = maintext().end().index()
file_end_line_num_plus_1 = maintext().index(f"{file_end}+1l linestart")
Expand Down Expand Up @@ -556,11 +556,9 @@ def move_selection_down(self, tag_type: str) -> None:
#
# If we are not in this situation, insert selected tag below the blank line we are at.
# Otherwise look for next blank line below that one.
if (
line_txt == ""
and not maintext().index(f"{line_num}-1l linestart")
== selected.last_line_num
):
if line_txt == "" and not maintext().index(
f"{line_num}-1l linestart"
) == maintext().index(f"{last_line_num} linestart"):
# If we are at the top of a block of blank lines, move the insertion
# point to the bottom of the block. If the 'block' is just a single blank
# line then the returned line_num is the same as the argument line_num.
Expand Down
Loading