This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dcb967b
New preference to be albe to scroll past the end of the file
TomMalbran efdfd90
Remove unnecesary script
TomMalbran eca77f0
Changes after initial review
TomMalbran 2ddd62c
Merge with master
TomMalbran c4190aa
Changes after Review
TomMalbran b72ae54
Reverse comment
TomMalbran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,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 | ||
|
@@ -98,6 +99,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); | ||
|
@@ -108,9 +110,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 */ | ||
|
||
|
@@ -231,22 +233,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 | ||
autoCloseBrackets : currentOptions[CLOSE_BRACKETS], | ||
autoCloseTags : currentOptions[CLOSE_TAGS], | ||
coverGutterNextToScrollbar : true, | ||
cursorScrollMargin : 3, | ||
dragDrop : false, | ||
electricChars : false, // we use our own impl of this to avoid CodeMirror bugs; see _checkElectricChars() | ||
extraKeys : codeMirrorKeyMap, | ||
indentUnit : currentOptions[USE_TAB_CHAR] ? currentOptions[TAB_SIZE] : currentOptions[SPACE_UNITS], | ||
indentWithTabs : currentOptions[USE_TAB_CHAR], | ||
lineNumbers : currentOptions[SHOW_LINE_NUMBERS], | ||
lineWrapping : currentOptions[WORD_WRAP], | ||
matchBrackets : true, | ||
matchTags : { bothTags: true }, | ||
scrollPastEnd : !range && currentOptions[SCROLL_PAST_END], | ||
smartIndent : currentOptions[SMART_INDENT], | ||
styleActiveLine : currentOptions[STYLE_ACTIVE_LINE], | ||
tabSize : currentOptions[TAB_SIZE] | ||
}); | ||
|
||
// Can't get CodeMirror's focused state without searching for | ||
|
@@ -1830,6 +1833,7 @@ define(function (require, exports, module) { | |
|
||
if (oldValue !== newValue) { | ||
this._currentOptions[prefName] = newValue; | ||
var useTabChar = this._currentOptions[USE_TAB_CHAR]; | ||
|
||
if (prefName === USE_TAB_CHAR) { | ||
this._codeMirror.setOption(cmOptions[prefName], newValue); | ||
|
@@ -1839,15 +1843,14 @@ define(function (require, exports, module) { | |
); | ||
} else if (prefName === STYLE_ACTIVE_LINE) { | ||
this._updateStyleActiveLine(); | ||
} else { | ||
} 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 | ||
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. Need to reverse the logic of this comment:
|
||
// that is in conflict with the useTabChar setting. | ||
var useTabChar = this._currentOptions[USE_TAB_CHAR]; | ||
if ((useTabChar && prefName === SPACE_UNITS) || | ||
(!useTabChar && prefName === TAB_SIZE)) { | ||
return; | ||
} | ||
|
||
return; | ||
} else { | ||
this._codeMirror.setOption(cmOptions[prefName], newValue); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.