Skip to content

Marks position after line delete / insert #290

@jacek-mulawka

Description

@jacek-mulawka

Probably a mark indicate a wrong line number after delete or insert a line.

The scenarios are:
add a mark (e.g. Ctrl + Shift + 1) somewhere in the middle lines (let say there are 10 lines at the document and I add a mark at the line 4) and

variant A - go to the end of the marked line (e.g. press End) and press Enter; the document have a new line and the mark moved to the line number 5 but I expect the mark stay at the line number 4 (to press Backspace or Delete move the mark again up).

variant B - go to the end of the marked line (e.g. press End) and press Delete; the document lost a line and the mark moved to the line number 3 but I expect the mark stay at the line number 4 (to press Enter move the mark again down).

variant C - go one line down (e.g. press Down Arrow) and press Enter; the document have a new line and the mark moved to the line number 5 but I expect the mark stay at the line number 4 (to press Backspace move the mark again up).

I am not sure whether marks should shift this way?

Probably the solution is to change the file SynEdit.pas. In procedures:

TCustomSynEdit.DoLinesDeleted
there is:
if Mark.Line >= FirstLine + Count then
Mark.Line := Mark.Line - Count
else if Mark.Line > FirstLine then
Mark.Line := FirstLine;

should be:
if Mark.Line > FirstLine + Count then
Mark.Line := Mark.Line - Count
else if Mark.Line > FirstLine + 1 then
Mark.Line := FirstLine;

procedure TCustomSynEdit.DoLinesInserted
there is:
if Mark.Line >= FirstLine then

should be:
if Mark.Line > FirstLine then

Another question is: should the mark shift down if the caret is somewhere inside the marked line (not the first and not the last position of the line) and I press Enter? I expect the mark stay.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions