julia-vscode
julia-vscode copied to clipboard
Codelens Support in `julia` Files
This PR attempts to support CodeLens for julia files (#858), enabling users to explore and execute code cells directly in the editor.
The initial commit only demonstrates the availability of CodeLens for julia files. To implement the complete functionality, there are two more tasks to be done.
- Currently, the
julia.executeCellcommand is used to execute code cells. However, the range of the code cell is reliant on the pointer position, where the trigger of CodeLens actions may not enclose the current pointer position. https://github.com/julia-vscode/julia-vscode/blob/9b009459727161f9292d2890d6c5433ec6932960/src/interactive/repl.ts#L856-L857
To address this issue, I propose two separate approaches:
- Workaround: Modify the
julia.executeCellcommand to execute either the code cell enclosing the pointer position or the code cell enclosing the CodeLens trigger position. - General solution: Strip and refactor all source code related to code cell execution to a more general approach used in the vscode-R extension (https://github.com/REditorSupport/vscode-R/blob/master/src/rmarkdown/chunks.ts). The new approach will statically analyze delimiters of all code cells and then dynamically locate the active code cell based on the executed CodeLens or pointer position. Though this approach may require more computation resources, it may provide a more robust and flexible solution for code cell execution.
I would like to hear the community's opinion on this issue. Either way, I'm willing to implement the solution.
- To introduce a new command
julia.executeAboveCellsto execute all code cells above the current pointer position if the second solution above is adopted, which is also a common feature in Jupyter notebooks and vscode-R extension.
- [ ] End-user documentation check. If this PR requires end-user documentation, please add that at https://github.com/julia-vscode/docs.
I didn't look at the linked implementation in detail, but that second approach seems preferable.