This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients JayKrish, Todd.Rovito, philwebster, terry.reedy
Date 2013-08-13.18:54:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376420089.38.0.742761473728.issue18583@psf.upfronthosting.co.za>
In-reply-to
Content
Based on working with the #18226 patch, I now think that rewrapping partial lines is a bug. Although I removed some problematical tests, I think there is still one that verifies buggy behavior. The outline of steps (which necessarily omits some details) would then be:

1. Extract a list of complete lines (without \n) from the text widget. The only purpose of using selections rather than the cursor would be to get partial paragraphs or multiple paragraphs. (I had thought of deleting that idea, but if you have made it work, I will look at it.)

There are still details to work out. If the cursor is on a blank line, should we really search forward? Normally, sel.first would be moved back to the beginning of the line [you apparently have already done this] and sel.last to the end. But if a block selection ends at the beginning of a line, sel.last should not be moved.

2. Delete the common prefix from each line, including '#' for comment blocks. Do this and the following without the current repeating joining of and splitting into lines. It is all wasted motion.

3. Reformat into a new list of lines, now with \n.

4. Add back the common prefix (still a list of lines with \n).

5. Insert the lines (which already have \n) into the text widget, one at a time.

   One of the details I left out is consistently handling of \n for the last line, so that deletion from the text widget and inserting into the widget match. One of the 'features' of the current code is that it will handle paragraphs with a different indent on the first line. I am not sure it is needed, as it does not apply to comment and string blocks.

Steps 2,3,4 do not involve the text widget. I think that they should be performed in one or more non-widget functions so they can be separately tested. I would feel this way even if mock_tk.Text were complete enough to substitute for tkinter.Text in the method test. 

I have not looked at your patch much because I want to review and possibly edit and commit some of the other submitted test patches before working more on this.
History
Date User Action Args
2013-08-13 18:54:49terry.reedysetrecipients: + terry.reedy, Todd.Rovito, JayKrish, philwebster
2013-08-13 18:54:49terry.reedysetmessageid: <1376420089.38.0.742761473728.issue18583@psf.upfronthosting.co.za>
2013-08-13 18:54:49terry.reedylinkissue18583 messages
2013-08-13 18:54:49terry.reedycreate