RFE: Overide GTK+ line selection behavior.

Bug #724660 reported by Matthias Niess on 2011-02-25
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Scribes Version: 0.4-dev-build899

I just found a really annoying bug. When you select multiple lines (e.g. by going to the begining of a line, holding shift and pressing the down-arrow a couple of time) you don't select the lines indicated by the highlighting but actually one line more. I assume this happens because the whitespace (i.e. \n) at the end of the line is selected, too. This creates several problems as described below.

1. create new .php or .py file and fill it with three paragraphs of lorem ipsum
2. put the cursor in the 2nd paragraph and press alt+p to select it
3. now press alt+c to comment it out

The blank line at the end of the paragraph is in the comment, too. Even though it wasn't intentionally selected.

Even worse, try this:
1. take the same file as above
2. move the cursor to the begining of a paragraph
3. select 2 lines by holding shift and pressing "down" twice
4. press alt+c to comment them out

3 lines are commented out instead of the two selected (highlighted) lines.

So any time you select multiple lines and want to do something to the selection, the affected text includes one more line. The only way to work around this is to make sure the selection doesn't include the \n manually (i.e. by pressing left while still holding SHIFT), Or by using the mouse...

Mystilleef (mystilleef) on 2011-02-25
Changed in scribes:
status: New → Triaged
importance: Undecided → Low
importance: Low → Wishlist
importance: Wishlist → Medium
assignee: nobody → Mystilleef (mystilleef)
Mystilleef (mystilleef) on 2011-02-28
Changed in scribes:
status: Triaged → Fix Committed
Matthias Niess (mniess) wrote :

Scribes version 0.4-dev-build954

This bug is still there in the above build.

Changed in scribes:
status: Fix Committed → Incomplete
status: Incomplete → Confirmed
Matthias Niess (mniess) wrote :

Here's a screencast of the bug. It is only fixed for pressing alt+p. If you manually select multiple lines, all operations (except copy&paste) affect the line after the selection, too.

summary: - Selections include white-space character(s) after the selection
+ Operations on selections have unexpected results

Maybe an operation on a selection should check for special white-space characters (like newline) on the end of selections and exclude them from the operation.

Matthias Niess (mniess) wrote :

Please let me know, if you need more information on this bug.

Mystilleef (mystilleef) wrote :

Not at the moment. This is not a Scribes bug per say. This is just how GTK+ handles selection. I may have to override selection handling.

Changed in scribes:
importance: Medium → Wishlist
summary: - Operations on selections have unexpected results
+ RFE: Overide GTK+ line selection behavior.
Matthias Niess (mniess) wrote :

Hm. Would it make sense to report this for GTK? Visually the selection looks the same as in gedit. Copy and paste or delete work as expected in both. It is just happening with scribes operations like commenting. Doing something similar in gedit works fine. What about checking if there is a newline (\n, \r or /n/r) at the end of the selection and exclude it before running any operations on selections? That way you could leave GTK's selection handling alone.

Mystilleef (mystilleef) wrote :

I think I already do that. I'll look into it again.

Matthias Niess (mniess) wrote :

Hey. Any progress on this? I know you regard this as "whishlist", but it messes with my code all the time because it always includes the line after the one I selected.

I really love your editor but this is killing me. Basically, you never know what happens with your selection. If I delete lines, only the selected lines will be deleted. With other things (like "filter through command") stuff outside the selection gets included. If you don't want to fix this (or don't have the time), can you point me in the right direction? I'm not a Python developer but I'd do anything to help.

Mystilleef (mystilleef) wrote :

It depends on the features you're having problems with. If it's filter through command, then look at the Plugin in question, look at if I'm doing anything crazy which selections, which I'm not, and strip the selection of newlines, which will cause unintended problems.

Scribes asks GTK for selected lines and uses what GTK tells it. I don't think I can do anything better than that at the moment. You're welcome to look in the code and see what I'm doing wrong.

Alternatively avoid using the mouse for selection and you Scribes selection functions, that may help some.

Matthias Niess (mniess) wrote :

I'm never using the mouse for selections. I'm selecting as described in this bug or using scribes functions like paragraph or line selection which cause these problems, too. I'll read some code at the weekend (and probably learn some python along the way). ;)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers