Skip to content

Commit 774497a

Browse files
committed
Re-mark everything when the active trace changes.
1 parent fb25a0d commit 774497a

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/editor-decorator.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
{Stacktrace} = require './stacktrace'
44

5+
markers = []
6+
57
module.exports = (editor) ->
8+
m.destroy() for m in markers
9+
markers = []
10+
611
active = Stacktrace.getActivated()
712
return unless active?
813

@@ -12,3 +17,4 @@ module.exports = (editor) ->
1217
marker = editor.markBufferRange range
1318
editor.decorateMarker marker, type: 'line', class: 'line-stackframe'
1419
editor.decorateMarker marker, type: 'gutter', class: 'gutter-stackframe'
20+
markers.push marker

lib/main.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module.exports =
1515
atom.emit 'stacktrace:accept-trace', trace: text
1616

1717
atom.workspace.eachEditor editorDecorator
18+
Stacktrace.on 'active-changed', ->
19+
editorDecorator(e) for e in atom.workspace.getEditors()
1820

1921
StacktraceView.registerIn(atom.workspace)
2022

@@ -24,6 +26,7 @@ module.exports =
2426
atom.workspace.open trace.getUrl()
2527

2628
deactivate: ->
29+
Stacktrace.off 'active-changed'
2730
atom.off 'stacktrace:accept-trace'
2831

2932
serialize: ->

spec/editor-marker-spec.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ describe 'editorDecorator', ->
5555
decorated = editorView.find '.line.line-stackframe'
5656
expect(decorated).toHaveLength 1
5757
expect(decorated.text()).toEqual(" puts 'this is the stack line'")
58+
59+
it 'removes prior decorations when deactivated', ->
60+
withEditorOn 'bottom.rb', ->
61+
editorDecorator(editor)
62+
trace.deactivate()
63+
editorDecorator(editor)
64+
expect(editorView.find '.line.line-stackframe').toHaveLength 0

0 commit comments

Comments
 (0)