diff --git a/spec/editor-view-spec.coffee b/spec/editor-view-spec.coffee index 9ef516613..26c52dbb5 100644 --- a/spec/editor-view-spec.coffee +++ b/spec/editor-view-spec.coffee @@ -2937,14 +2937,14 @@ describe "EditorView", -> .editor { line-height: 2; } """ - expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 32, left: 30} - expect(editorView.getCursorView().position()).toEqual {top: 32, left: 30} + expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 20, left: 30} + expect(editorView.getCursorView().position()).toEqual {top: 20, left: 30} atom.themes.applyStylesheet 'char-width', """ .editor { letter-spacing: 2px; } """ - expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 32, left: 36} - expect(editorView.getCursorView().position()).toEqual {top: 32, left: 36} + expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 20, left: 36} + expect(editorView.getCursorView().position()).toEqual {top: 20, left: 36} describe "when the editor contains hard tabs", -> it "correctly calculates the the position left for a column", -> diff --git a/src/editor-view.coffee b/src/editor-view.coffee index a2148516e..ffd09dd92 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -44,6 +44,7 @@ class EditorView extends View @configDefaults: fontFamily: '' fontSize: 16 + lineHeight: 1.3 showInvisibles: false showIndentGuide: false showLineNumbers: true @@ -340,6 +341,8 @@ class EditorView extends View @subscribe atom.config.observe 'editor.invisibles', (invisibles) => @setInvisibles(invisibles) @subscribe atom.config.observe 'editor.fontSize', (fontSize) => @setFontSize(fontSize) @subscribe atom.config.observe 'editor.fontFamily', (fontFamily) => @setFontFamily(fontFamily) + @subscribe atom.config.observe 'editor.lineHeight', (lineHeight) => @setLineHeight(lineHeight) + handleEvents: -> @on 'focus', => @@ -747,6 +750,14 @@ class EditorView extends View # Returns a {String} identifying the CSS `font-family`. getFontFamily: -> @css("font-family") + # Public: Sets the line height of the editor + # + # lineHeight - A {Number} without a unit suffix identifying the CSS + # `line-height`. + setLineHeight: (lineHeight) -> + @css('line-height', lineHeight) + @redraw() + # Public: Redraw the editor redraw: -> return unless @hasParent()