# Debugging/modifying functions stack without reloading all the code

**URL:** <https://discourse.julialang.org/t/debugging-modifying-functions-stack-without-reloading-all-the-code/44432>\
**Category:** VS Code\
**Created:** [August 6, 2020, 4:34pm UTC](https://discourse.julialang.org/t/debugging-modifying-functions-stack-without-reloading-all-the-code/44432 "2020-08-06T16:34:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anj](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anj](https://discourse.julialang.org/u/anj)\
**Post date:** [August 6, 2020, 4:34pm UTC](https://discourse.julialang.org/t/debugging-modifying-functions-stack-without-reloading-all-the-code/44432/1 "2020-08-06T16:34:33Z")

</div>

say I have `foo()` calling `bar()` and the bug is in the second one

```julia
using Printf

function foo()
    bar()
end

function bar()
    println("bar 1")
end

```

I run `@run foo()` all good `bar 1` is printed out (in real live, found bug, fixed 😉 ). Now I modify `bar` like this

```julia
function bar()
    println("bar 1")
    println("bar 2")
end

```

I press `Alt+Enter` on this function. and if I just call `foo()` in REPL, all good I see two line output. however if I call `@run foo()` the debugger doesn’t pick up the modified code.

Is there a way to make debugger pick up latest code same way as REPL does?  
(I found that running `Alt+Enter` on `foo` makes debugger pick up latest `bar`. but I am looking for something more elegant. i.e. if I have 10 function deep stack it is bit impractical.)

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [August 6, 2020, 6:26pm UTC](https://discourse.julialang.org/t/debugging-modifying-functions-stack-without-reloading-all-the-code/44432/2 "2020-08-06T18:26:18Z")

</div>

Short answer is “no”.

The Alt+Enter is processed by VS Code and passes the contents of the file you are interested in running to Julia for processing. Typing `@run foo()` into Julia, VS Code has no idea that you did that, so there is no way for it to push the latest code to Julia.

I don’t know the internals of VS Code, there _might_ be a way to detect focus switch (or something else) and force VS Code to push the latest source into Julia. However I think this might do more harm than good since anytime you move to the Julia pane there would be a delay as VS Code & Julia “sync” the code. Additionally this “feature” would most likely run afoul of projects with multiple modules and multiple source files, unless the VS Code module did a whole lot more parsing of the Julia files to know the structure of the whole application.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [August 6, 2020, 6:39pm UTC](https://discourse.julialang.org/t/debugging-modifying-functions-stack-without-reloading-all-the-code/44432/3 "2020-08-06T18:39:39Z")

</div>

There’s something wrong in how VSCode interfaces with the interpreter.

```julia
using JuliaInterpreter

function foo()
    bar()
end

function bar()
    println("bar 1")
end

foo()
@interpret foo()

function bar()
    println("bar 1")
    println("bar 2")
end

foo()
@interpret foo()

```

works as expected, so the Debugger should too. Will look into this.
