Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions lib/php-debug.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module.exports = PhpDebug =

@GlobalContext.onStackChange (codepoint) =>
@doCodePoint(codepoint)

@GlobalContext.onSocketError () =>
@toggleDebugging()

Expand Down Expand Up @@ -172,19 +172,19 @@ module.exports = PhpDebug =
for breakpoint in event.removed
if breakpoint.getMarker()
breakpoint.getMarker().destroy()

atom.workspace.observeTextEditors (editor) =>
if (atom.config.get('php-debug.GutterBreakpointToggle'))
@createGutter editor
else
else
for breakpoint in @GlobalContext.getBreakpoints()
if breakpoint.getPath() == editor.getPath()
marker = @addBreakpointMarker(breakpoint.getLine(), editor)
breakpoint.setMarker(marker)

atom.config.observe "php-debug.GutterBreakpointToggle", (newValue) =>
@createGutters newValue
@createGutters newValue

atom.config.observe "php-debug.GutterPosition", (newValue) =>
@createGutters atom.config.get('php-debug.GutterBreakpointToggle'),true

Expand All @@ -193,6 +193,8 @@ module.exports = PhpDebug =
command: 'php-debug:addWatch'
shouldDisplay: =>
editor = atom.workspace.getActivePaneItem()
if (!editor || !editor.getSelectedText)
return false
expression = editor?.getSelectedText()
if !!expression then return true else return false
},
Expand All @@ -202,6 +204,7 @@ module.exports = PhpDebug =
shouldDisplay: =>
editor = atom.workspace.getActivePaneItem()
return false if !editor
return false if !editor.getSelectedBufferRange
range = editor.getSelectedBufferRange()
path = editor.getPath()
line = range.getRows()[0]+1
Expand Down Expand Up @@ -242,7 +245,7 @@ module.exports = PhpDebug =
filepath = point.getPath()

filepath = helpers.remotePathToLocal(filepath)

atom.workspace.open(filepath,{searchAllPanes: true, activatePane:true}).then (editor) =>
if @currentCodePointDecoration
@currentCodePointDecoration.destroy()
Expand All @@ -258,12 +261,12 @@ module.exports = PhpDebug =
addBreakpointMarker: (line, editor) ->
gutter = editor.gutterWithName("php-debug-gutter")
range = [[line-1, 0], [line-1, 0]]

marker = new BreakpointMarker(editor,range,gutter)
marker.decorate()

return marker


breakpointSettings: ->
BreakpointSettingsView = require './breakpoint/breakpoint-settings-view'
Expand All @@ -278,54 +281,55 @@ module.exports = PhpDebug =
break
@settingsView = new BreakpointSettingsView({breakpoint:breakpoint,context:@GlobalContext})
@settingsView.attach()

createGutters: (create,recreate) ->
editors = atom.workspace.getTextEditors()
for editor in editors
if editor
if create == false
if (!editor || !editor.gutterWithName)
return
if create == false
if (editor?.gutterWithName('php-debug-gutter') != null)
gutter = editor?.gutterWithName('php-debug-gutter')
gutter?.destroy()
else
if recreate
if (editor?.gutterWithName('php-debug-gutter') != null)
gutter = editor?.gutterWithName('php-debug-gutter')
gutter?.destroy()
else
if recreate
if (editor?.gutterWithName('php-debug-gutter') != null)
gutter = editor?.gutterWithName('php-debug-gutter')
gutter?.destroy()
if (editor?.gutterWithName('php-debug-gutter') == null)
@createGutter(editor)

if (editor?.gutterWithName('php-debug-gutter') == null)
@createGutter(editor)

createGutter: (editor) ->
if (!editor)
editor = atom.workspace.getActivePaneItem()

if (!editor || !editor.gutterWithName)
return

gutterEnabled = atom.config.get('php-debug.GutterBreakpointToggle')
if (!gutterEnabled)
return

gutterPosition = atom.config.get('php-debug.GutterPosition')
if gutterPosition == "Left"
priority = -200
else
priority = 200

if (editor.gutterWithName('php-debug-gutter') != null)
@gutter = editor.gutterWithName('php-debug-gutter')
return
else
@gutter = editor?.gutterContainer.addGutter {name:'php-debug-gutter', priority: priority}

view = atom.views.getView editor
domNode = atom.views.getView @gutter
$(domNode).unbind 'click.phpDebug'
$(domNode).bind 'click.phpDebug', (event) =>
clickedScreenRow = view.component.screenPositionForMouseEvent(event).row
clickedBufferRow = editor.bufferRowForScreenRow(clickedScreenRow)+1
@toggleBreakpoint clickedBufferRow

if @gutter
for breakpoint in @GlobalContext.getBreakpoints()
if breakpoint.getPath() == editor.getPath()
Expand All @@ -350,9 +354,9 @@ module.exports = PhpDebug =
@getUnifiedView().setVisible(false)
@statusView?.setActive(false)
return

@createGutter()

else
@getUnifiedView().setVisible(false)
@statusView?.setActive(false)
Expand Down