Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Create new file with %edit magic (IPython console) #17181

Merged
merged 4 commits into from
Feb 17, 2022
Merged
Changes from 2 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
4 changes: 4 additions & 0 deletions spyder/plugins/ipythonconsole/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,10 @@ def tab_name_editor(self):
@Slot(object, object)
def edit_file(self, filename, line):
"""Handle %edit magic petitions."""
if not osp.isfile(filename):
impact27 marked this conversation as resolved.
Show resolved Hide resolved
# Create new file
with open(filename, "w") as f:
f.write("")
impact27 marked this conversation as resolved.
Show resolved Hide resolved
if encoding.is_text_file(filename):
# The default line number sent by ipykernel is always the last
# one, but we prefer to use the first.
Expand Down