Zim

[pyzim] Reopen current page will insert extra newline between tasks

Bug #478564 reported by Ben Lau
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zim
Status tracked in Pyzim
Pyzim
Fix Released
High
Unassigned

Bug Description

Steps to reproduce the problem

1. Create a wiki page with following content. (Call it "Testing")

Project 1
[] Task 1
[] Task 2
Project 2
[] Task 2

2. Inside the index view , click on the "Testing" page.

3. You will find that extra newlines was inserted between tasks. The content becomes:

Project 1
[] Task 1

[] Task 2

Project 2

[] Task 2

Revision history for this message
Ben Lau (benlau) wrote :

I have traced the code , and find a very simple (dirty?) method to solve the problem. It may add a condition checking at the start of PageView.set_page().

Example:

def set_page(self, page):

    if self.page == page:
        return

    # for some reason keeping a copy of the previous buffer

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

I'm sorry but that simple hack can not be used. The reason being that we should go through the parser loop when "Reload page" is pressed. This is a feature that allows the user to type some wiki syntax and press ^R to render it in WYSIWYG fashion.

Can you reproduce this error in a systematic way? That woudl help greatly to pinpoint the root cause.

I did see this before, but so far am unable to always reproduce it.

Revision history for this message
Ben Lau (benlau) wrote :

hmm... let see is this one a more systematic way (If there have any unit test framework , then the task will be much simpler ):

Steps to reproduce the problem:

1. Go to the directory of any zim wiki

2. Run the following command to produce a wiki page called "Testing"

cat << EOF > Testing.txt
Project 1
[ ] Task 1
[ ] Task 2
Project 2
[ ] Task 2
EOF

3. Launch pyzim , and click on the "Testing" page in page index or in pathbar.

4. "Testing.txt" will be changed to :

Project 1
[ ] Task 1

[ ] Task 2

Project 2
[ ] Task 2

5. Click on "Testing" page again , more extra lines are added

Project 1
[ ] Task 1

[ ] Task 2

Project 2
[ ] Task 2

Revision history for this message
smu (smu) wrote :

a similiar problem which is maybe connected:

create a list:

* one
* two
* three

save the page and insert an additional space in front of the second bullet:

* one
 * two
* three

reload the page:

• one

• two

• three

Revision history for this message
smu (smu) wrote :

uh, I just found something else which is maybe also connected:

create a list or task list as mentioned before and double-click on the page name in the index.
Each double-click inserts additional newlines between the items.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Assigned to pyzim series - please open pyzim specific items on the actual series for a better overview. Thanks.

Changed in zim:
status: New → Invalid
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Ok, took some time to diagnose. It is crucial to note that this only shows if you open the page by clicking in the side pane, not on e.g. reload.

The reason is that in that case the same parsetree is used and no loop is made storing in wiki text and loading it again. Apparently the tree as produced by the editor is not fully roundtrip safe without dumping to text first :(

Will implemented a dirty fix for now by blocking the side pane from loading the same page twice. However will leave the bug open because this for sure will return sooner or later without a proper fix.

Would help if we can make tests/pageview.py fail for this issue - from a quick look I expect it should fail already, but it doesn't at the moment :(

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Believe to have the final fix for this in rev 153.

Found that existing unit test was not failing because the bug changed both the result and the value against which the result was tested ... so testing was not paranoid enough. Added extra check to fail if the test value is changed.

The test case with a space in front of a bullet still shows a change in formatting, this is because the space is not recognized as indenting, use a tab for that.

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.