Skip to content
This repository was archived by the owner on Aug 28, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Do not jump to top of the file every time a debugging session starts
- Updating settings now updates current project's settings as well
- Deleting current project doesn't break pugdebug any more
- Breakpoints do not dissapear any more when debugging multiple requests

### Removed

Expand Down
53 changes: 16 additions & 37 deletions pugdebug/pugdebug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

class Pugdebug(QObject):

init_breakpoints = []
breakpoints = []

def __init__(self):
Expand Down Expand Up @@ -472,7 +471,7 @@ def start_listening(self):

start_debugging = True

if break_at_first_line == 0 and len(self.init_breakpoints) == 0:
if break_at_first_line == 0 and len(self.breakpoints) == 0:
messageBox = QMessageBox()
messageBox.setText("There are no breakpoints set and the break at"
" first line setting is turned off.")
Expand Down Expand Up @@ -525,7 +524,7 @@ def handle_debugging_started(self):
return

post_start_data = {
'init_breakpoints': self.init_breakpoints
'breakpoints': self.breakpoints
}
self.debugger.post_start_command(post_start_data)

Expand Down Expand Up @@ -563,12 +562,6 @@ def handle_debugging_stopped(self):
This handler should be called when the connection to
xdebug is terminated.
"""
# Only set breakpoints as init_breakpoints
# if there are any breakpoints set
if len(self.breakpoints) > 0:
self.init_breakpoints = self.breakpoints
self.breakpoints = []

self.main_window.toggle_actions(False)

self.main_window.set_debugging_status(2)
Expand Down Expand Up @@ -664,22 +657,22 @@ def set_breakpoint(self, breakpoint):
"""Set a breakpoint

If there is no active debugging session, add the breakpoint data to
the initial breakpoints, highlight the init breakpoints on the line
the breakpoints, highlight the breakpoints on the line
numbers of the documents, and show them in the breakpoint viewer.

If there is an active debugging session, tell the debugger to set the
breakpoint.
"""
if not self.debugger.is_connected():
self.init_breakpoints.append(breakpoint)
self.breakpoints.append(breakpoint)

path = breakpoint['filename']
path = self.__get_path_mapped_to_local(path)

document_widget = self.document_viewer.get_document_by_path(path)
document_widget.rehighlight_breakpoint_lines()

self.breakpoint_viewer.set_breakpoints(self.init_breakpoints)
self.breakpoint_viewer.set_breakpoints(self.breakpoints)

return

Expand All @@ -689,7 +682,7 @@ def remove_breakpoint(self, breakpoint):
"""Remove a breakpoint

If there is no active debugging session, just remove the breakpoint
from the initial breakpoints, rehighlight the line numbers for
from the breakpoints, rehighlight the line numbers for
breakpoint markers and update the breakpoint viewer.

If there is an active debugging session, tell the debugger to remove
Expand All @@ -699,17 +692,17 @@ def remove_breakpoint(self, breakpoint):
path = breakpoint['filename']
line_number = breakpoint['lineno']

for init_breakpoint in self.init_breakpoints:
if (init_breakpoint['filename'] == path and
init_breakpoint['lineno'] == line_number):
self.init_breakpoints.remove(init_breakpoint)
for breakpoint in self.breakpoints:
if (breakpoint['filename'] == path and
breakpoint['lineno'] == line_number):
self.breakpoints.remove(breakpoint)

path = self.__get_path_mapped_to_local(path)

document_widget = self.document_viewer.get_document_by_path(path)
document_widget.rehighlight_breakpoint_lines()

self.breakpoint_viewer.set_breakpoints(self.init_breakpoints)
self.breakpoint_viewer.set_breakpoints(self.breakpoints)

return

Expand All @@ -727,20 +720,11 @@ def remove_stale_breakpoints(self, path):
"""
remote_path = self.__get_path_mapped_to_remote(path)

breakpoints = []

if self.debugger.is_connected():
breakpoints = list(filter(
lambda breakpoint: breakpoint['filename'] != remote_path,
self.breakpoints
))
self.breakpoints = breakpoints
else:
breakpoints = list(filter(
lambda breakpoint: breakpoint['filename'] != remote_path,
self.init_breakpoints
))
self.init_breakpoints = breakpoints
breakpoints = list(filter(
lambda breakpoint: breakpoint['filename'] != remote_path,
self.breakpoints
))
self.breakpoints = breakpoints

self.breakpoint_viewer.set_breakpoints(breakpoints)

Expand Down Expand Up @@ -783,11 +767,6 @@ def get_breakpoint(self, path, line_number):
int(breakpoint['lineno']) == line_number):
return breakpoint

for breakpoint in self.init_breakpoints:
if (breakpoint['filename'] == path and
int(breakpoint['lineno']) == line_number):
return breakpoint

return None

def handle_breakpoints_listed(self, breakpoints):
Expand Down
6 changes: 3 additions & 3 deletions pugdebug/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ def set_debugger_features(self):
def __post_start(self, data):
post_start_response = {
'debugger_features': self.__set_debugger_features(),
'init_breakpoints': self.__set_init_breakpoints(
data['init_breakpoints']
'breakpoints': self.__set_breakpoints(
data['breakpoints']
),
'breakpoints': self.__list_breakpoints()
}
Expand Down Expand Up @@ -376,7 +376,7 @@ def __get_stacktraces(self):

return stacktraces

def __set_init_breakpoints(self, breakpoints):
def __set_breakpoints(self, breakpoints):
all_successful = True

for breakpoint in breakpoints:
Expand Down