SCI_PARAUPEXTEND doesn't match expectations
If I have three "paragraphs": two which are "example" multiple times, enough that it triggers word-wrap, and the third being three newline-separated lines
If I start at the "3" on line #3 (the middle of the second paragraph) and use Ctrl+Shift+{ to trigger SCI_PARAUPEXTEND, instead of selecting to the beginning of the current paragraph, it selects to the beginning of the previous paragraph.
However, if I start at the "7" on line #7 (the middle of the third paragraph) and use Ctrl+Shift+{ to trigger SCI_PARAUPEXTEND, it selects to the start of the third paragraph as expected.
Using unshifted Ctrl+{ or Ctrl+} SCI_PARAUP/SCI_PARADOWN to navigate finds only four paragraphs, starting at 1, 3, 6, and 10... so obviously, it considers all of line 3 to be a single paragraph and the three lines 6-9 to be a single paragraph. So it seems strange that starting "in the middle of a paragraph" changes behavior for SCI_PARAUP/SCI_PARAUPEXTEND depending on whether that paragraph is a single line wrapped across multiple visible lines or a multiple lines without extra newlines between.

(Originally found in Notepad++ v8.4.7 which uses the v5.3.1 library, and verified in Windows SciTE v5.3.1, so it's definitely part of the scintilla library behavior)
Paragraph movement was contributed long ago and I don't use it so I'll just try to explain what the code is doing.
The
ParaUpcode is only concerned with document lines - wrapping has no effect. It only examines whether each document line is blank - contains nothing or just spaces and tabs.From (3, which is 2 in code), it goes (line--) to 1, first loop skips 1 to 0, second loop skips 0 to -1, then final line++ -> 0 which is 1 to the user,
From (7 (code: 6)), it goes (line--) to 5 which is not empty so the first loop doesn't run and the second loop goes to 4 then terminates as 4 is empty and the final line++ arrives at 5 which is line 6 for user.
If you start from the 'e' immediately above the '7' then
ParaUpgoes to line 3.My point is that ParaUp behaves differently depending on where in the paragraph you are in. If you are on the second (physical) line or beyond of a given paragraph, then ParaUp will take you to the start of that paragraph. If you are on the first (physical) line of a given paragraph, then ParaUp will take you to the start of the previous paragraph.
I think that is what the original developer intended as a way to move between paragraph start lines.
ParaUpmoves to the starting line of the current paragraph but, when at the starting line of a paragraph, move to the starting line of the previous paragraph.Its similar to word movement with Ctrl+Left: when inside a word, move to the start of that word but, when at word start, move to start of previous word.
Interestingly, I would say that your analogy works better for my argument. If you have the phrase
the word, and the caret is immediately before thew, then the caret is at the beginning of the wordword, and so aCtrl+Leftshould take you tothe; but if the caret is between thewand theo, then the caret is not at the beginning of the wordword, soCtrl+Leftshould take you to the start ofword.Similarly, the digit
3in my example paragraph is not at the beginning of the paragraph: it's well into the middle of that paragraph. The only place I would consider the caret to be at the beginning of the paragraph is when the caret is before the firsteof that paragraph.But at this point, I can't do anything more to show you my perspective (or that of other users of software that uses the Scintilla library). It is now in your hands whether you consider this a bug, or not worth fixing because most users have just resigned themselves to the (seemingly) inconsistent behavior, or working as designed. It is your library, not mine, after all.
The code is deliberate in its behaviour so it appears to me to be implementing the author's intention. Other contributors that have worked around here also appear satisfied by the behaviour. So I'm not going to treat it as a bug.
So far, you have said what you don't like but you haven't defined the behaviour you do want. Alternative behaviour could be included as an option. Its also possible for applications to implement their own actions.
In my example above, putting the caret at the
3and then doing ParaUp should take you to the line labled 3 (which is internally line 2). If the caret were already at the beginning of that line (before thee), then it would still take you to the beginning of the line labeled 1.This could be accomplished by changing
to
(for a properly defined
current_caret_column, which is presumably already available or easily obtainable)I can duplicate the requested behaviour in WordPad by using
Ctrl+Shift+Up.Shift+Upalso gets the preceding EOL sequence. The caret disappears during the operation so cannot state where it actually is located.Notepad does a line based selection using
Shift+UpandCtrl+Shift+Updoes nothing. Tested also the latest notepad with Windows 11 in VirtualBox.If changed, may break existing third party code that relies on it and disrupt existing users habits. I do not use these paragraph functions often, if ever, so I will not lose much sleep over a change. Perhaps could notify on scite-Interest and other related sites for any objections before changing?
The motivation for the feature change would be just to be consistent with Wordpad. I do not know about other (word processor) applications and what they do in comparison.
This is what I tested with:
I tried with
GetColumn(pos)though could not resolve the GCC errors about "discard the qualifier" so went withLineStart(line).It is more like Wordpad in selecting to the start of paragraph before proceding up to the next paragraph. If the paragraph is indented then it appears to operate similar to Wordpad.
Referred to the mailing lists for objections.
LineStartis more efficient butGetColumncould and should be made const.No objections on the mailing list so committed with [11b83e] .
Related
Commit: [11b83e]
No objections on the mailing list so committed with [11b83e] .
Related
Commit: [11b83e]