diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index b8e5c524b..43d020705 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -932,14 +932,16 @@ describe "Editor", -> expect(editor.hiddenInput).toMatchSelector ':focus' describe "when the hidden input is focused / unfocused", -> - it "assigns the isFocused flag on the editor", -> + it "assigns the isFocused flag on the editor and also adds/removes the .focused css class", -> editor.attachToDom() editor.isFocused = false editor.hiddenInput.focus() expect(editor.isFocused).toBeTruthy() + expect(editor).toHaveClass('focused') editor.hiddenInput.focusout() expect(editor.isFocused).toBeFalsy() + expect(editor).not.toHaveClass('focused') describe "construction", -> it "assigns an empty buffer and correctly handles text input (regression coverage)", -> diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index cdfe83472..2fbeae95e 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -108,8 +108,13 @@ class Editor extends View @hiddenInput.focus() false - @hiddenInput.on 'focus', => @isFocused = true - @hiddenInput.on 'focusout', => @isFocused = false + @hiddenInput.on 'focus', => + @isFocused = true + @addClass 'focused' + + @hiddenInput.on 'focusout', => + @isFocused = false + @removeClass 'focused' @on 'mousedown', '.fold-placeholder', (e) => @destroyFold($(e.currentTarget).attr('foldId')) diff --git a/static/editor.css b/static/editor.css index 9aa87418c..4e42c87af 100644 --- a/static/editor.css +++ b/static/editor.css @@ -67,11 +67,15 @@ .editor .cursor { position: absolute; - border-left: 3px solid #9dff9d; + border-left: 3px solid rgba(255, 255, 255, .4); opacity: 0.7; } -.editor .cursor.idle { +.editor.focused .cursor { + border-color: #9dff9d; +} + +.editor.focused .cursor.idle { -webkit-animation: blink 0.6s; -webkit-animation-iteration-count: infinite; }