diff --git a/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java b/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java index 6f7a2e48a50f..d9dfa9c57ae9 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java @@ -13,7 +13,7 @@ import java.io.IOException; public interface IPyDebugProcess extends PyFrameAccessor { PyPositionConverter getPositionConverter(); - void threadSuspended(PyThreadInfo thread); + void threadSuspended(PyThreadInfo thread, boolean updateSourcePosition); boolean canSaveToTemp(String name); diff --git a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java index c1ec611eda85..fac6d5eccc20 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java @@ -586,8 +586,13 @@ public class RemoteDebugger implements ProcessDebugger { thread.updateState(PyThreadInfo.State.SUSPENDED, event.getFrames()); thread.setStopReason(event.getStopReason()); thread.setMessage(event.getMessage()); - myDebugProcess.threadSuspended(thread); - myDebugProcess.suspendAllOtherThreads(thread); + boolean updateSourcePosition = true; + if (event.getStopReason() == AbstractCommand.SUSPEND_THREAD) { + // That means that the thread was stopped manually from the Java side either while suspending all threads + // or after the "Pause" command. In both cases we shouldn't change debugger focus if session is already suspended. + updateSourcePosition = !myDebugProcess.getSession().isSuspended(); + } + myDebugProcess.threadSuspended(thread, updateSourcePosition); break; } case AbstractCommand.RESUME_THREAD: { @@ -611,7 +616,7 @@ public class RemoteDebugger implements ProcessDebugger { // notify UI of suspended threads left in debugger if one thread finished its work if ((threadInfo != null) && (threadInfo.getState() == PyThreadInfo.State.SUSPENDED)) { myDebugProcess.threadResumed(threadInfo); - myDebugProcess.threadSuspended(threadInfo); + myDebugProcess.threadSuspended(threadInfo, true); } } } diff --git a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java index 48e274f635f0..fec912e655af 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java @@ -798,7 +798,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr } @Override - public void threadSuspended(final PyThreadInfo threadInfo) { + public void threadSuspended(final PyThreadInfo threadInfo, boolean updateSourcePosition) { if (!mySuspendedThreads.contains(threadInfo)) { mySuspendedThreads.add(threadInfo); @@ -821,14 +821,20 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr breakpoint = myRegisteredExceptionBreakpoints.get(exceptionName); } } - if (breakpoint != null) { - if (!getSession().breakpointReached(breakpoint, threadInfo.getMessage(), suspendContext)) { - resume(suspendContext); - } + // add check for breakpoint type + suspendAllOtherThreads(threadInfo); } - else { - getSession().positionReached(suspendContext); + + if (updateSourcePosition) { + if (breakpoint != null) { + if (!getSession().breakpointReached(breakpoint, threadInfo.getMessage(), suspendContext)) { + resume(suspendContext); + } + } + else { + getSession().positionReached(suspendContext); + } } } }