GTG

Unexpected new line is inserted after links

Bug #346970 reported by Pititjo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GTG
Fix Released
High
Unassigned

Bug Description

An unexpected new line is introduced after url. For reproduce the bug :
- Create a new task
- add an url into it
- close the task editor
- reopen it

I join a patch witch refactor the serializer parse_buffer method and fix the problem. It fix problems with imbricate gtkTextTag too.

Tags: toreview
Revision history for this message
Pititjo (jonathan-barnoud) wrote :
tags: added: toreview
Changed in gtg:
assignee: nobody → ploum
importance: Undecided → High
milestone: none → 0.1.1
status: New → Confirmed
Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

pitijo > it seems nice but the while True is really ugly. I don't want to have while True / break, it's opening the door to a lot of problem.

Also, the line :
tags = [ta for ta in it.get_tags() if it.begins_tag(ta) and ta not in done and is_know_tag(ta)]

is really unclear and should not be done like this. Please split that line into several logical components.

Can you also comment a bit more your code ?

Last but not least, you make on this bug a summary of what your patch changes so people less familiar with the code could see the benefit ;-)

Thanks a lot :-)

tags: removed: toreview
Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

(oh and, like you did, add the "toreview" tag once you want advice for your patch. I will not touch this code at all so you can concentrate on your patch and no porting stuffs)

Revision history for this message
Pititjo (jonathan-barnoud) wrote :

Original parse_buffer method, witch translate the gtkTextBuffer in xml, is unable to process recursive gtkTextTag because when a gtkTextTag is beginning the method process each gtkTextTag witch applies to the gtkTextIter rather than process only the gtkTextTag witch is beginning.

The original method has problem with unknown gtkTextTag too and the one witch describe url is (and must be) unknown by the parser.

My new method browse the buffer when a gtkTextTag begins the method search the gtkTextTeag end before process it. So the new parser is able to parse imbricate gtkTextTag. If a gtkTextTag is unknown it is ignored.

It's very hard to explain with my bad English. I hope it is understandable.

I post a new patch without the while True, without the tags = [ta for ta in it.get_tags() if it.begins_tag(ta) and ta not in done and is_know_tag(ta)] and with commentaries.

tags: added: toreview
Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

Traceback (most recent call last):
  File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 43, in serialize
    doc.appendChild(self.parse_buffer(content_buf,its, ite,parent,doc))
  File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 114, in parse_buffer
    parent.appendChild(child)
UnboundLocalError: local variable 'child' referenced before assignment
Traceback (most recent call last):
  File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 43, in serialize
    doc.appendChild(self.parse_buffer(content_buf,its, ite,parent,doc))
  File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 134, in parse_buffer
    if last_val and last_val.nodeValue[-1] != '\n' :
TypeError: 'NoneType' object is unsubscriptable

Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

I tried to create a task with subtasks, http links and tags.

Revision history for this message
Pititjo (jonathan-barnoud) wrote : Re: [Bug 346970] Re: Unexpected new line is inserted after links

Le jeudi 26 mars 2009 à 12:41 +0000, Lionel Dricot a écrit :
> Traceback (most recent call last):
> File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 43, in serialize
> doc.appendChild(self.parse_buffer(content_buf,its, ite,parent,doc))
> File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 114, in parse_buffer
> parent.appendChild(child)
> UnboundLocalError: local variable 'child' referenced before assignment
> Traceback (most recent call last):
> File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 43, in serialize
> doc.appendChild(self.parse_buffer(content_buf,its, ite,parent,doc))
> File "/home/ploum/gtg.local/GTG/taskeditor/taskviewserial.py", line 134, in parse_buffer
> if last_val and last_val.nodeValue[-1] != '\n' :
> TypeError: 'NoneType' object is unsubscriptable
>

I saw this traceback even before I refactor the method but I don't know
how to reproduce it. Do you know what you did ?

Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

Pitijo : There's 2 tracebacks.

The first, on line 114, seems to be your fault (you use child in a "else" without initializing this child

The second one is my fault and is solved by making line 134 looks like :

if last_val and last_val.nodeType == 3 and last_val.nodeValue[-1] != '\n' :

Revision history for this message
Pititjo (jonathan-barnoud) wrote :

I didn't see the first traceback.
This patch fix my bug and include ploum's fix.

Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

I've merged your patch but I think that there are still a few issues (I've seen sometimes a blank lines inserted between the title and a subtask). But anyway, it should be better than what we have right now, traces are fixed.

Changed in gtg:
status: Confirmed → Fix Committed
Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) wrote :

Pitijo > I merged a previous version of your patch. Could you please check the trunk ?

Revision history for this message
Pititjo (jonathan-barnoud) wrote :

It seem good.

Changed in gtg:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.