mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Merge pull request #14495 from warrenpnz/maxScreenLineLength
Enable MAX_SCREEN_LINE_LENGTH to now be set via a config option
This commit is contained in:
@@ -544,6 +544,21 @@ describe('TextEditorRegistry', function () {
|
||||
expect(editor.getSoftWrapColumn()).toBe(80)
|
||||
})
|
||||
|
||||
it('allows for custom definition of maximum soft wrap based on config', async function () {
|
||||
editor.update({
|
||||
softWrapped: false,
|
||||
maxScreenLineLength: 1500,
|
||||
})
|
||||
|
||||
expect(editor.getSoftWrapColumn()).toBe(1500)
|
||||
|
||||
atom.config.set('editor.softWrap', false)
|
||||
atom.config.set('editor.maxScreenLineLength', 500)
|
||||
registry.maintainConfig(editor)
|
||||
await initialPackageActivation
|
||||
expect(editor.getSoftWrapColumn()).toBe(500)
|
||||
})
|
||||
|
||||
it('sets the preferred line length based on the config', async function () {
|
||||
editor.update({preferredLineLength: 80})
|
||||
expect(editor.getPreferredLineLength()).toBe(80)
|
||||
|
||||
@@ -74,6 +74,7 @@ describe "TextEditor", ->
|
||||
expect(editor2.getInvisibles()).toEqual(editor.getInvisibles())
|
||||
expect(editor2.getEditorWidthInChars()).toBe(editor.getEditorWidthInChars())
|
||||
expect(editor2.displayLayer.tabLength).toBe(editor2.getTabLength())
|
||||
expect(editor2.displayLayer.softWrapColumn).toBe(editor2.getSoftWrapColumn())
|
||||
|
||||
describe "when the editor is constructed with the largeFileMode option set to true", ->
|
||||
it "loads the editor but doesn't tokenize", ->
|
||||
@@ -145,7 +146,7 @@ describe "TextEditor", ->
|
||||
returnedPromise = editor.update({
|
||||
tabLength: 6, softTabs: false, softWrapped: true, editorWidthInChars: 40,
|
||||
showInvisibles: false, mini: false, lineNumberGutterVisible: false, scrollPastEnd: true,
|
||||
autoHeight: false
|
||||
autoHeight: false, maxScreenLineLength: 1000
|
||||
})
|
||||
|
||||
expect(returnedPromise).toBe(element.component.getNextUpdatePromise())
|
||||
@@ -5918,3 +5919,11 @@ describe "TextEditor", ->
|
||||
describe "::getElement", ->
|
||||
it "returns an element", ->
|
||||
expect(editor.getElement() instanceof HTMLElement).toBe(true)
|
||||
|
||||
describe 'setMaxScreenLineLength', ->
|
||||
it "sets the maximum line length in the editor before soft wrapping is forced", ->
|
||||
expect(editor.getSoftWrapColumn()).toBe(500)
|
||||
editor.update({
|
||||
maxScreenLineLength: 1500
|
||||
})
|
||||
expect(editor.getSoftWrapColumn()).toBe(1500)
|
||||
|
||||
@@ -409,6 +409,12 @@ const configSchema = {
|
||||
minimum: 1,
|
||||
description: 'Identifies the length of a line which is used when wrapping text with the `Soft Wrap At Preferred Line Length` setting enabled, in number of characters.'
|
||||
},
|
||||
maxScreenLineLength: {
|
||||
type: 'integer',
|
||||
default: 500,
|
||||
minimum: 500,
|
||||
description: 'Defines the maximum width of the editor window before soft wrapping is enforced, in number of characters.'
|
||||
},
|
||||
tabLength: {
|
||||
type: 'integer',
|
||||
default: 2,
|
||||
|
||||
@@ -18,6 +18,7 @@ const EDITOR_PARAMS_BY_SETTING_KEY = [
|
||||
['editor.softWrapHangingIndent', 'softWrapHangingIndentLength'],
|
||||
['editor.softWrapAtPreferredLineLength', 'softWrapAtPreferredLineLength'],
|
||||
['editor.preferredLineLength', 'preferredLineLength'],
|
||||
['editor.maxScreenLineLength', 'maxScreenLineLength'],
|
||||
['editor.autoIndent', 'autoIndent'],
|
||||
['editor.autoIndentOnPaste', 'autoIndentOnPaste'],
|
||||
['editor.scrollPastEnd', 'scrollPastEnd'],
|
||||
|
||||
@@ -17,7 +17,6 @@ TextEditorElement = null
|
||||
{isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isWrapBoundary} = require './text-utils'
|
||||
|
||||
ZERO_WIDTH_NBSP = '\ufeff'
|
||||
MAX_SCREEN_LINE_LENGTH = 500
|
||||
|
||||
# Essential: This class represents all essential editing state for a single
|
||||
# {TextBuffer}, including cursor and selection positions, folds, and soft wraps.
|
||||
@@ -158,7 +157,7 @@ class TextEditor extends Model
|
||||
@assert, grammar, @showInvisibles, @autoHeight, @autoWidth, @scrollPastEnd, @scrollSensitivity, @editorWidthInChars,
|
||||
@tokenizedBuffer, @displayLayer, @invisibles, @showIndentGuide,
|
||||
@softWrapped, @softWrapAtPreferredLineLength, @preferredLineLength,
|
||||
@showCursorOnSelection
|
||||
@showCursorOnSelection, @maxScreenLineLength
|
||||
} = params
|
||||
|
||||
@assert ?= (condition) -> condition
|
||||
@@ -183,6 +182,7 @@ class TextEditor extends Model
|
||||
@softWrapped ?= false
|
||||
@softWrapAtPreferredLineLength ?= false
|
||||
@preferredLineLength ?= 80
|
||||
@maxScreenLineLength ?= 500
|
||||
@showLineNumbers ?= true
|
||||
|
||||
@buffer ?= new TextBuffer({
|
||||
@@ -323,6 +323,11 @@ class TextEditor extends Model
|
||||
@preferredLineLength = value
|
||||
displayLayerParams.softWrapColumn = @getSoftWrapColumn()
|
||||
|
||||
when 'maxScreenLineLength'
|
||||
if value isnt @maxScreenLineLength
|
||||
@maxScreenLineLength = value
|
||||
displayLayerParams.softWrapColumn = @getSoftWrapColumn()
|
||||
|
||||
when 'mini'
|
||||
if value isnt @mini
|
||||
@mini = value
|
||||
@@ -433,7 +438,7 @@ class TextEditor extends Model
|
||||
softWrapHangingIndentLength: @displayLayer.softWrapHangingIndent
|
||||
|
||||
@id, @softTabs, @softWrapped, @softWrapAtPreferredLineLength,
|
||||
@preferredLineLength, @mini, @editorWidthInChars, @width, @largeFileMode,
|
||||
@preferredLineLength, @mini, @editorWidthInChars, @width, @largeFileMode, @maxScreenLineLength,
|
||||
@registered, @invisibles, @showInvisibles, @showIndentGuide, @autoHeight, @autoWidth
|
||||
}
|
||||
|
||||
@@ -3039,7 +3044,7 @@ class TextEditor extends Model
|
||||
else
|
||||
@getEditorWidthInChars()
|
||||
else
|
||||
MAX_SCREEN_LINE_LENGTH
|
||||
@maxScreenLineLength
|
||||
|
||||
###
|
||||
Section: Indentation
|
||||
|
||||
Reference in New Issue
Block a user