Skip to content

Commit

Permalink
Pass fully resolved file path to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Cube707 authored and rec committed Jan 4, 2024
1 parent ae2808f commit 124c1b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def editor(
if text is not None:
path.write_text(text)

cmd = '{} {}'.format(editor, fname)
cmd = '{} "{}"'.format(editor, path.resolve())
runs.call(cmd, **kwargs)
return path.read_text()

Expand Down
9 changes: 6 additions & 3 deletions test_editor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import unittest
from unittest import mock

Expand All @@ -17,9 +18,10 @@ def test_existing(self, call):
expected = FILENAME + '\n'
assert actual == expected

call.assert_called_once_with('{} {}'.format(EDITOR, FILENAME))
filename = Path(FILENAME).resolve()
call.assert_called_once_with('{} "{}"'.format(EDITOR, filename))

actual = editor('X', filename=FILENAME)
actual = editor('X', filename=filename)
expected = 'X'
assert actual == expected

Expand All @@ -29,7 +31,8 @@ def test_new(self, call):
expected = 'X'
assert actual == expected

expected = '{} {}'.format(EDITOR, FILENAME)
filename = Path(FILENAME).resolve()
expected = '{} "{}"'.format(EDITOR, filename)
call.assert_called_once_with(expected, shell=True)

def test_temp(self, call):
Expand Down

0 comments on commit 124c1b7

Please sign in to comment.