#475 BugFix for #4293: bad cursor position on files > 998 lines


This patch fixes bug #4293

All text changes (and all caret position changes) will remember the caret's new horizontal position when moving to different lines. However, the horizontal position is not measured in characters but in pixels from the left side of the window.
Between the left side of the window and the text pane there is the margin pane (i.e. line number margin, bookmark margin and folding margin).
When the size of the margin pane is changed, then the horizontal position of the text changes but not the remembered caret's horizontal position relative to the window. Thus moving then the caret to a different line will result in a jump in column position.

Such jumps in column positions from line to line could be observed after e.g.:
- enable or disable the bookmark margin
- ZoomIn or ZoomOut (ctrl-num + or ctrl-num -), which changes the size of the characters
- always for TrueType fonts with non equidistant characters
- and finally changing the size of the line number margin

This behaviour is part of Scintilla windows control library, which is used by Notepad++. It can be observed also in SciTE, the Scintilla own editor, which has the same issue when enable/disable its "fold margin".

Reason of bug:
Notepad++ sets the line number margin to 3 digits by default and adapts the line number margin when the window is scrolled to 4 digit line numbers. When jumping back to the first line, the line number margin is reduced after the jump is performed. Therefore, the remembered horizontal position from the left window size is not updated correctly.

A work around is to press two times ctrl-home!

I have generated a patch, which sets the line number margin width to the digit number of the maximum lines in the file and does not adapt the line number margin when moving through the file.

Furthermore, some dead code is commented, which is to be deleted lateron.

Commentcode: xNoLineNumberMarginSizeUpdate:
Patch: NppPatch_6.3.2_NoLineNumberMarginSizeUpdate.patch against SVN-revision 1037

1 Attachments


  • Neomi

    Neomi - 2013-07-21

    Hi FLS, I just made patch #509, which fixes the same bug(s), but preserves the dynamic line number margin width.

    While searching through similar bugs, I found bug #2192, which is more of a feature request for a fixed margin width. So your fix should still be good as an alternate behavior if it could be made optional in the user preferences.

  • Don HO

    Don HO - 2013-09-19
    • status: open --> closed
  • Don HO

    Don HO - 2013-09-19

    This bug has been fixed in v6.4.5



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks