macdown icon indicating copy to clipboard operation
macdown copied to clipboard

[Feature] Scroll past end

Open schickling opened this issue 12 years ago • 14 comments

I think it would be convenient if one would be able to scroll past the end of a page. I current always end up adding line breaks at the end of a document in order to not crawl on the last line.

Sublime Text for example also has this feature: http://sublimetext.userecho.com/topic/101697-ability-to-over-scroll/

schickling avatar Jul 12 '14 13:07 schickling

Yes, this feature is essential for me as well. BTW, Brackets also has a setting for this. And Atom has an extension.

ghost avatar Aug 25 '14 23:08 ghost

Definitely a "nice to have". Not a big deal, but nice.

masukomi avatar Aug 26 '14 02:08 masukomi

I’ve toyed with some implementations a bit, but can’t decide on some details. I can make the editor scroll past end (not that hard), but don’t really know how much I should make it able to scroll past end. Any suggestions?

uranusjr avatar Aug 29 '14 11:08 uranusjr

Scroll so much until you just see the last line at the top

schickling avatar Aug 29 '14 12:08 schickling

FWIMC: Dev build! This is based on 0.2.4.

I wish to make sure I get the behaviours correct before implementing the UI details, so there is currently no way to turn off scrolling past end. But please do try it out and tell me what you think. :)

This build is not available from the in-app update.

uranusjr avatar Sep 01 '14 08:09 uranusjr

I tried the dev build. It scrolls too far. Personally I'm fine with anything from 1/4 of the frame being blank space at the bottom all the way to @schickling's comment of "Scroll so much until you just see the last line at the top". My personal preference is to have roughly 1/4 of the frame being blank from scrolling past the bottom.

I definitely think you should not be able to scroll so far that you can't see ANY of your text, which is the case in the dev build.

masukomi avatar Sep 10 '14 02:09 masukomi

I tried out a few other editors myself:

  • Sublime Text: Only the last line is visible.
  • Atom (with Scroll Past End plugin): Keeps the last three lines are visible by default, and offers an option to keep half a screen visible.
  • Visual Studio: Only the last line is visible.
  • Notepad++ (with ScrollPastEOF plugin): Only the last line is visible.

So I just went with the most popular implementation. You should be able to see the last line (and maybe the line before that if you have a large enough vertical inset), but maybe it seems like it doesn’t exist because it’s empty. Since MacDown doesn’t have line numbers now, maybe an improvement would be to disregard lines with whitespace characters only, and keep the last line with actual content visible instead. It’s also possible to add a preference, but that seems like an overkill to me.

uranusjr avatar Sep 10 '14 04:09 uranusjr

Yes. I like that solution, only i'd be a bit more specific. Last line with visible characters. A line with 20 tabs and 400 spaces would be just as useless as a line with nothing. Keeping in mind that if you support the display of invisible characters in the future then those tabs and spaces would be "visible characters".

masukomi avatar Sep 11 '14 18:09 masukomi

Yes, that’s exactly what I had in mind, too. Tabs, spaces, carriage returns, newlines, and whatever is defined as whitespace characters in Unicode don’t count as contents.

uranusjr avatar Sep 12 '14 00:09 uranusjr

Second test build here. This implements the aforementioned “ignore trailing junk” behaviour. I also added the UI checkbox for toggling the feature, so you can also play with it if you want to.

As always, any feedback is welcomed. :)

uranusjr avatar Sep 12 '14 10:09 uranusjr

works for me. :)

I wonder if this should be the default behavior or not.

The downside to it being the default is that users might think there's extra blank lines that aren't really there.

I think the optimal solution would be to change the background for everything below the last line with user entered characters. Necessary? no. Nice-to-have? yeah.

I'd still be happy to have this shipped as-is.

masukomi avatar Sep 17 '14 17:09 masukomi

I’m more inclined to make it an opt-in. I don’t think it’s possible to make the trailing space have a different background, at least not without some serious hacking.

I’m more inclined to make it an opt-in so that newcomers don’t get confused. It might be helpful if the checkbox has a more descriptive label, though. “Scroll past end” doesn’t really mean anything unless you already know what it is. Perhaps something like Add extra height at the end of the content?

uranusjr avatar Sep 18 '14 03:09 uranusjr

I feel like it scrolls too far. I added the code below to my theme to adjust it to my liking

.CodeMirror-lines { padding-bottom: 400px !important; };

seriypshick avatar Feb 12 '15 11:02 seriypshick

The how far part is subjective, so there’s no way I can come up with a perfect value. I think the current behaviour is pretty widely-used, so I’m sticking with that. Maybe it’s possible to add an option for this, but I don’t know how it should be configured—a fixed height won’t be enough because the document window sizes will vary. Also, the current behaviour is “keep the last line visible,” and I don’t know how to configure that. But any suggestions are always welcomed.

uranusjr avatar Feb 12 '15 15:02 uranusjr