Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

New preference to be able to scroll past the end of the file #7142

Merged
merged 6 commits into from
Mar 13, 2014

Conversation

TomMalbran
Copy link
Contributor

Since is sometimes hard to write at the bottom of the screen, this allows you to scroll past the end until the point that the last line becomes the first line in view. This can be enabled with a new preference which is disabled by default.

@redmunds redmunds self-assigned this Mar 10, 2014
extraKeys : codeMirrorKeyMap,
autoCloseBrackets : currentOptions[CLOSE_BRACKETS],
autoCloseTags : currentOptions[CLOSE_TAGS],
scrollPastEnd : !range ? currentOptions[SCROLL_PAST_END] : false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flip this around so the else case is not a double-negative:

    range ? false : currentOptions[SCROLL_PAST_END]

@redmunds
Copy link
Contributor

I just noticed that the vertical scrollbar goes behind the little square in bottom-right corner. Removing the .CodeMirror-scrollbar-filler rule fixes that.

@redmunds
Copy link
Contributor

Done with review.

@TomMalbran
Copy link
Contributor Author

I just noticed that the vertical scrollbar goes behind the little square in bottom-right corner.

That has happened ever since we added custom scrollbars for the editor. Check this recent conversation #5083 (comment)

Removing the .CodeMirror-scrollbar-filler rule fixes that.

Do you mean that it just goes to the bottom of the file or it actually stops where it should? If is the first one, we still have a bug, since both the horizontal and vertical thumbs would overlap at that corner.

@redmunds
Copy link
Contributor

Removing the .CodeMirror-scrollbar-filler rule fixes that.

Do you mean that it just goes to the bottom of the file or it actually stops where it should?

The vertical scroll thumb is already going to the bottom of the file even when there is a horizontal scroll bar, but the .CodeMirror-scrollbar-filler element is covering it up. I, personally, would prefer that it does not go all the way to the bottom in this case, but hiding part of the thumb is probably worse -- especially in files with a lot of lines and a small thumb.

The horizontal scroll thumb does not go into that corner, so there is no overlap.

But, this is for another pull request -- I just thought I'd mention it.

@TomMalbran
Copy link
Contributor Author

I actually can see the horizontal bar go beneath the vertical one. I would like if the scrollbars stop where they should. Notice that there is a min width in the thumb, so it will never be too small to not be able to grab it to scroll up. We should fill a new issue for that.

Pushed the fixes for this PR.

@@ -55,6 +55,7 @@
<script src="thirdparty/CodeMirror2/addon/edit/matchbrackets.js"></script>
<script src="thirdparty/CodeMirror2/addon/edit/closebrackets.js"></script>
<script src="thirdparty/CodeMirror2/addon/edit/closetag.js"></script>
<script src="thirdparty/CodeMirror2/addon/scroll/scrollpastend.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeMirror v4 changed how addons are loaded, so merge to the latest master add a require() for this.

@redmunds
Copy link
Contributor

@TomMalbran I'm ready to merge this into master, but there's 1 change you need to make.

@TomMalbran
Copy link
Contributor Author

@redmunds Merged with master and fixed the require issue.

@@ -1847,6 +1850,10 @@ define(function (require, exports, module) {
(!useTabChar && prefName === TAB_SIZE)) {
return;
}
// Do not apply this option to inline editors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an awkward place to check this, this seems better:

            } else if (prefName === STYLE_ACTIVE_LINE) {
                this._updateStyleActiveLine();
            } else if (prefName === SCROLL_PAST_END && this._visibleRange) {
                // Do not apply this option to inline editors
                return;
            } else {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that looks better. If we assign the useTabChar var at line 1836, we could make the if at line 1849 be an else if too.

@redmunds
Copy link
Contributor

Done with review. One more comment.

@TomMalbran
Copy link
Contributor Author

@redmunds Changes pushed.

} else if (prefName === SCROLL_PAST_END && this._visibleRange) {
// Do not apply this option to inline editors
return;
} else if ((useTabChar && prefName === SPACE_UNITS) || (!useTabChar && prefName === TAB_SIZE)) {
// Set the CodeMirror option as long as it's not a change
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to reverse the logic of this comment:

// This change conflicts with the useTabChar setting,
// so do not change the CodeMirror option

@TomMalbran
Copy link
Contributor Author

@redmunds fixed

@redmunds
Copy link
Contributor

Looks good. Merging.

redmunds added a commit that referenced this pull request Mar 13, 2014
New preference to be able to scroll past the end of the file
@redmunds redmunds merged commit db59b6f into master Mar 13, 2014
@redmunds redmunds deleted the tom/scroll-past-end branch March 13, 2014 23:42
@TomMalbran
Copy link
Contributor Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants