-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New preference to be able to scroll past the end of the file #7142
Changes from 2 commits
dcb967b
efdfd90
eca77f0
2ddd62c
c4190aa
b72ae54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ define(function (require, exports, module) { | |
STYLE_ACTIVE_LINE = "styleActiveLine", | ||
WORD_WRAP = "wordWrap", | ||
CLOSE_TAGS = "closeTags", | ||
SCROLL_PAST_END = "scrollPastEnd", | ||
cmOptions = {}; | ||
|
||
// Mappings from Brackets preferences to CodeMirror options | ||
|
@@ -97,6 +98,7 @@ define(function (require, exports, module) { | |
cmOptions[STYLE_ACTIVE_LINE] = "styleActiveLine"; | ||
cmOptions[WORD_WRAP] = "lineWrapping"; | ||
cmOptions[CLOSE_TAGS] = "autoCloseTags"; | ||
cmOptions[SCROLL_PAST_END] = "scrollPastEnd"; | ||
|
||
PreferencesManager.definePreference(SMART_INDENT, "boolean", true); | ||
PreferencesManager.definePreference(USE_TAB_CHAR, "boolean", false); | ||
|
@@ -107,9 +109,9 @@ define(function (require, exports, module) { | |
PreferencesManager.definePreference(STYLE_ACTIVE_LINE, "boolean", false); | ||
PreferencesManager.definePreference(WORD_WRAP, "boolean", true); | ||
PreferencesManager.definePreference(CLOSE_TAGS, "Object", { whenOpening: true, whenClosing: true, indentTags: [] }); | ||
PreferencesManager.definePreference(SCROLL_PAST_END, "boolean", false); | ||
|
||
var editorOptions = [SMART_INDENT, USE_TAB_CHAR, TAB_SIZE, SPACE_UNITS, CLOSE_BRACKETS, | ||
SHOW_LINE_NUMBERS, STYLE_ACTIVE_LINE, WORD_WRAP, CLOSE_TAGS]; | ||
var editorOptions = Object.keys(cmOptions); | ||
|
||
/** Editor preferences */ | ||
|
||
|
@@ -386,22 +388,23 @@ define(function (require, exports, module) { | |
// Create the CodeMirror instance | ||
// (note: CodeMirror doesn't actually require using 'new', but jslint complains without it) | ||
this._codeMirror = new CodeMirror(container, { | ||
electricChars: false, // we use our own impl of this to avoid CodeMirror bugs; see _checkElectricChars() | ||
smartIndent: currentOptions[SMART_INDENT], | ||
indentWithTabs: currentOptions[USE_TAB_CHAR], | ||
tabSize: currentOptions[TAB_SIZE], | ||
indentUnit: currentOptions[USE_TAB_CHAR] ? currentOptions[TAB_SIZE] : currentOptions[SPACE_UNITS], | ||
lineNumbers: currentOptions[SHOW_LINE_NUMBERS], | ||
lineWrapping: currentOptions[WORD_WRAP], | ||
styleActiveLine: currentOptions[STYLE_ACTIVE_LINE], | ||
coverGutterNextToScrollbar: true, | ||
matchBrackets: true, | ||
matchTags: {bothTags: true}, | ||
dragDrop: false, | ||
extraKeys: codeMirrorKeyMap, | ||
autoCloseBrackets: currentOptions[CLOSE_BRACKETS], | ||
autoCloseTags: currentOptions[CLOSE_TAGS], | ||
cursorScrollMargin: 3 | ||
electricChars : false, // we use our own impl of this to avoid CodeMirror bugs; see _checkElectricChars() | ||
smartIndent : currentOptions[SMART_INDENT], | ||
indentWithTabs : currentOptions[USE_TAB_CHAR], | ||
tabSize : currentOptions[TAB_SIZE], | ||
indentUnit : currentOptions[USE_TAB_CHAR] ? currentOptions[TAB_SIZE] : currentOptions[SPACE_UNITS], | ||
lineNumbers : currentOptions[SHOW_LINE_NUMBERS], | ||
lineWrapping : currentOptions[WORD_WRAP], | ||
styleActiveLine : currentOptions[STYLE_ACTIVE_LINE], | ||
coverGutterNextToScrollbar : true, | ||
matchBrackets : true, | ||
matchTags : { bothTags: true }, | ||
dragDrop : false, | ||
extraKeys : codeMirrorKeyMap, | ||
autoCloseBrackets : currentOptions[CLOSE_BRACKETS], | ||
autoCloseTags : currentOptions[CLOSE_TAGS], | ||
scrollPastEnd : !range ? currentOptions[SCROLL_PAST_END] : false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flip this around so the else case is not a double-negative:
|
||
cursorScrollMargin : 3 | ||
}); | ||
|
||
// Can't get CodeMirror's focused state without searching for | ||
|
@@ -1572,6 +1575,10 @@ define(function (require, exports, module) { | |
(!useTabChar && prefName === TAB_SIZE)) { | ||
return; | ||
} | ||
// Do not apply this option to inline editors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like an awkward place to check this, this seems better:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, that looks better. If we assign the |
||
if (prefName === SCROLL_PAST_END && this._visibleRange) { | ||
return; | ||
} | ||
|
||
this._codeMirror.setOption(cmOptions[prefName], newValue); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
<script src="thirdparty/CodeMirror2/addon/selection/active-line.js"></script> | ||
|
||
<!-- JS for CodeMirror multiplex and overlay mode support --> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now enough params being passed that I think these should be sorted alphabetically to make it easier to see what's specified.