Skip to content
This repository was archived by the owner on Aug 28, 2020. It is now read-only.

Commit bf946c9

Browse files
committed
remove init breakpoints, there is no need for them, we can do everything with just the breakpoints
1 parent e688097 commit bf946c9

File tree

1 file changed

+16
-37
lines changed

1 file changed

+16
-37
lines changed

pugdebug/pugdebug.py

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
class Pugdebug(QObject):
2929

30-
init_breakpoints = []
3130
breakpoints = []
3231

3332
def __init__(self):
@@ -472,7 +471,7 @@ def start_listening(self):
472471

473472
start_debugging = True
474473

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

527526
post_start_data = {
528-
'init_breakpoints': self.init_breakpoints
527+
'init_breakpoints': self.breakpoints
529528
}
530529
self.debugger.post_start_command(post_start_data)
531530

@@ -563,12 +562,6 @@ def handle_debugging_stopped(self):
563562
This handler should be called when the connection to
564563
xdebug is terminated.
565564
"""
566-
# Only set breakpoints as init_breakpoints
567-
# if there are any breakpoints set
568-
if len(self.breakpoints) > 0:
569-
self.init_breakpoints = self.breakpoints
570-
self.breakpoints = []
571-
572565
self.main_window.toggle_actions(False)
573566

574567
self.main_window.set_debugging_status(2)
@@ -664,22 +657,22 @@ def set_breakpoint(self, breakpoint):
664657
"""Set a breakpoint
665658
666659
If there is no active debugging session, add the breakpoint data to
667-
the initial breakpoints, highlight the init breakpoints on the line
660+
the breakpoints, highlight the breakpoints on the line
668661
numbers of the documents, and show them in the breakpoint viewer.
669662
670663
If there is an active debugging session, tell the debugger to set the
671664
breakpoint.
672665
"""
673666
if not self.debugger.is_connected():
674-
self.init_breakpoints.append(breakpoint)
667+
self.breakpoints.append(breakpoint)
675668

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

679672
document_widget = self.document_viewer.get_document_by_path(path)
680673
document_widget.rehighlight_breakpoint_lines()
681674

682-
self.breakpoint_viewer.set_breakpoints(self.init_breakpoints)
675+
self.breakpoint_viewer.set_breakpoints(self.breakpoints)
683676

684677
return
685678

@@ -689,7 +682,7 @@ def remove_breakpoint(self, breakpoint):
689682
"""Remove a breakpoint
690683
691684
If there is no active debugging session, just remove the breakpoint
692-
from the initial breakpoints, rehighlight the line numbers for
685+
from the breakpoints, rehighlight the line numbers for
693686
breakpoint markers and update the breakpoint viewer.
694687
695688
If there is an active debugging session, tell the debugger to remove
@@ -699,17 +692,17 @@ def remove_breakpoint(self, breakpoint):
699692
path = breakpoint['filename']
700693
line_number = breakpoint['lineno']
701694

702-
for init_breakpoint in self.init_breakpoints:
703-
if (init_breakpoint['filename'] == path and
704-
init_breakpoint['lineno'] == line_number):
705-
self.init_breakpoints.remove(init_breakpoint)
695+
for breakpoint in self.breakpoints:
696+
if (breakpoint['filename'] == path and
697+
breakpoint['lineno'] == line_number):
698+
self.breakpoints.remove(breakpoint)
706699

707700
path = self.__get_path_mapped_to_local(path)
708701

709702
document_widget = self.document_viewer.get_document_by_path(path)
710703
document_widget.rehighlight_breakpoint_lines()
711704

712-
self.breakpoint_viewer.set_breakpoints(self.init_breakpoints)
705+
self.breakpoint_viewer.set_breakpoints(self.breakpoints)
713706

714707
return
715708

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

730-
breakpoints = []
731-
732-
if self.debugger.is_connected():
733-
breakpoints = list(filter(
734-
lambda breakpoint: breakpoint['filename'] != remote_path,
735-
self.breakpoints
736-
))
737-
self.breakpoints = breakpoints
738-
else:
739-
breakpoints = list(filter(
740-
lambda breakpoint: breakpoint['filename'] != remote_path,
741-
self.init_breakpoints
742-
))
743-
self.init_breakpoints = breakpoints
723+
breakpoints = list(filter(
724+
lambda breakpoint: breakpoint['filename'] != remote_path,
725+
self.breakpoints
726+
))
727+
self.breakpoints = breakpoints
744728

745729
self.breakpoint_viewer.set_breakpoints(breakpoints)
746730

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

786-
for breakpoint in self.init_breakpoints:
787-
if (breakpoint['filename'] == path and
788-
int(breakpoint['lineno']) == line_number):
789-
return breakpoint
790-
791770
return None
792771

793772
def handle_breakpoints_listed(self, breakpoints):

0 commit comments

Comments
 (0)