Skip to content

Commit

Permalink
Adjusts issue #38 when line wrapped (#38: HOME key, could put caret o…
Browse files Browse the repository at this point in the history
…n first non-space position)

When wrapping is enabled and we are at the final of one line SelStart could return the same value as if we were at the beginning of the next one (*). In that case, pressing HOME would move the cursor incorrectly to the first character of next line.

(*): That occurs when we go to that position pressing 'End'. If we move (left arrow) from the beginning of the next line, the cursor will be apparently in the same position, but in the first case it will be as if we were in the next line.

Signed-off-by: Daniel Prado Velasco <dpradov@users.noreply.github.com>
  • Loading branch information
dpradov committed Jan 5, 2016
1 parent 01849f4 commit 1d785b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kn_Main.pas
Expand Up @@ -2755,9 +2755,14 @@ procedure TForm_Main.RxRTFKeyDown(Sender: TObject; var Key: Word;
end;
VK_HOME: begin
getInformationOfCurrentLine(TRxRichEdit(sender));
if ((TRxRichEdit(sender).SelStart > (posFirstChar + indent)) or (TRxRichEdit(sender).SelStart = posFirstChar) ) then begin
if ((TRxRichEdit(sender).SelStart > (posFirstChar + indent)) or
((maxIndent>0) and (TRxRichEdit(sender).SelStart = posFirstChar)) ) then begin
TRxRichEdit(sender).SelStart:= posFirstChar + maxIndent;
key:= 0;
// Apparently it wouldn't matter if we entered if (maxIndent=0), but when
// wrapping is enabled and we are at the final of one line SelStart can return the
// same value as if we were at the beginning of the next one. In that case, the cursor
// would move incorrectly to the first character of next line.
end;
end;

Expand Down

0 comments on commit 1d785b3

Please sign in to comment.