madflow / flow-netbeans-markdown

Markdown file support for the NetBeans IDE
MIT License
278 stars 40 forks source link

Please add an option to change refresh time. #64

Closed Chris2011 closed 9 years ago

Chris2011 commented 9 years ago

For me, the refreshtime of the preview (I split my view, so I can see both, code and preview at the same time) the refresh time is a bit to slow. I would like to change this, not each would like to have a faster or slower refreshtime so I think an option to set the refresh time would be very nice. For chrome there is an Markdown extension too, this has no delay time "type smth -> instant reload".

Regards

Chris

madflow commented 9 years ago

@stengerh Would it be sane to reduce the delay time for updating the preview? I believe the update time is set to 1000 ms at the moment.

stengerh commented 9 years ago

I chose this value arbitrarily. Using a very low value or zero could lead to significant CPU usage for large Markdown documents. Other than that there should be no ill effect from lowering the delay.

Chris2011 commented 9 years ago

So I would suggest an option so that the user can choose the delay itself. Would be better than to change the delay each time.

madflow commented 9 years ago

@Chris2011 I have compiled a new release with the pull request #74 (thanks to @rmburkhead) - which implements this feature. Please note that the underlying Markdown parser is rather build for accuracy and extendibility than speed. So even if you set the delay to the minumum of 10 microseconds - the parser will still have to do some work. Maybe you can do quick test on your end?

rmburkhead commented 9 years ago

@Chris2011 @madflow 10 ms was chosen rather arbitrarily as an insane lower limit. It seemed to work OK on a reasonably sized file (the official Markdown syntax page), but might blow up on a chapter-sized or novel-sized md file. I did not profile the task scheduling for the preview refresh, but it might be worth doing this on a sufficiently large file to see when the tasks start colliding.

To my eye, 100 ms (and even 250 ms) seemed reasonably responsive. It might be better to increase the lower limit to some similar, more reasonable number if no one can profile the threads on a huge file.

Chris2011 commented 9 years ago

Wow it works like a charm :D. I tested this file: http://daringfireball.net/projects/markdown/syntax.text round about 890 lines of syntax and it's quite fast with 50ms.

I copied the lines to get a file with about 5000 lines and it's fast enough for me. I don't think, that you will find such big files, in a happy case.

Thx for the nice feature. But one is a little bit a pain in the ass. When I have such big file, where I have to scroll, and I scroll to the last position and add new text, the cursor ALWAYS scrolls to the top. I splitted my view so I have source and preview at the same time. But I will create a new ticket for this. This ticket here can be closed.

madflow commented 9 years ago

Thanks for the test. Yep - jumping to the top is a known "feature" (Before #42 the preview jumped to the bottom, either way feels wrong). We'll appreciate a new issue ticket.