mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Add editor.showLineNumbers config option
Also adds toggle-line-numbers command. Closes #377
This commit is contained in:
@@ -1707,6 +1707,12 @@ describe "Editor", ->
|
||||
miniEditor.setText(" a line with tabs\tand spaces ")
|
||||
expect(miniEditor.renderedLines.find('.line').text()).toBe "#{space}a line with tabs#{tab} and spaces#{space}"
|
||||
|
||||
describe "when config.editor.showLineNumbers is false", ->
|
||||
it "doesn't render any line numbers", ->
|
||||
expect(editor.gutter.lineNumbers).toBeVisible()
|
||||
config.set("editor.showLineNumbers", false)
|
||||
expect(editor.gutter.lineNumbers).not.toBeVisible()
|
||||
|
||||
describe "gutter line highlighting", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom(heightInLines: 5.5)
|
||||
|
||||
@@ -16,6 +16,7 @@ class Editor extends View
|
||||
fontSize: 20
|
||||
showInvisibles: false
|
||||
showIndentGuide: false
|
||||
showLineNumbers: true
|
||||
autoIndent: true
|
||||
autoIndentOnPaste: false
|
||||
nonWordCharacters: "./\\()\"':,.;<>~!@#$%^&*|+=[]{}`~?-"
|
||||
@@ -156,6 +157,7 @@ class Editor extends View
|
||||
'editor:duplicate-line': @duplicateLine
|
||||
'editor:toggle-indent-guide': => config.set('editor.showIndentGuide', !config.get('editor.showIndentGuide'))
|
||||
'editor:save-debug-snapshot': @saveDebugSnapshot
|
||||
'editor:toggle-line-numbers': => config.set('editor.showLineNumbers', !config.get('editor.showLineNumbers'))
|
||||
|
||||
documentation = {}
|
||||
for name, method of editorBindings
|
||||
@@ -316,6 +318,7 @@ class Editor extends View
|
||||
backwardsScanInRange: (args...) -> @getBuffer().backwardsScanInRange(args...)
|
||||
|
||||
configure: ->
|
||||
@observeConfig 'editor.showLineNumbers', (showLineNumbers) => @gutter.setShowLineNumbers(showLineNumbers)
|
||||
@observeConfig 'editor.showInvisibles', (showInvisibles) => @setShowInvisibles(showInvisibles)
|
||||
@observeConfig 'editor.showIndentGuide', (showIndentGuide) => @setShowIndentGuide(showIndentGuide)
|
||||
@observeConfig 'editor.invisibles', (invisibles) => @setInvisibles(invisibles)
|
||||
|
||||
@@ -24,6 +24,9 @@ class Gutter extends View
|
||||
editor: ->
|
||||
@parentView
|
||||
|
||||
setShowLineNumbers: (showLineNumbers) ->
|
||||
if showLineNumbers then @lineNumbers.show() else @lineNumbers.hide()
|
||||
|
||||
updateLineNumbers: (changes, renderFrom, renderTo) ->
|
||||
if renderFrom < @firstScreenRow or renderTo > @lastScreenRow
|
||||
performUpdate = true
|
||||
|
||||
Reference in New Issue
Block a user