summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qutebrowser/config/configdata.yml6
-rw-r--r--qutebrowser/misc/editor.py2
-rw-r--r--tests/unit/misc/test_editor.py6
3 files changed, 10 insertions, 4 deletions
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index 3f5e0b640..95338b36f 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -1435,12 +1435,16 @@ editor.command:
* `{line0}`: Same as `{line}`, but starting from index 0.
* `{column0}`: Same as `{column}`, but starting from index 0.
-
editor.encoding:
type: Encoding
default: utf-8
desc: Encoding to use for the editor.
+editor.remove_file:
+ default: true
+ type: Bool
+ desc: Delete the temporary file upon closing the editor.
+
## fileselect
fileselect.handler:
diff --git a/qutebrowser/misc/editor.py b/qutebrowser/misc/editor.py
index d561a7b96..3ef84284d 100644
--- a/qutebrowser/misc/editor.py
+++ b/qutebrowser/misc/editor.py
@@ -135,7 +135,7 @@ class ExternalEditor(QObject):
message.error("Failed to create initial file: {}".format(e))
return
- self._remove_file = True
+ self._remove_file = config.val.editor.remove_file
line, column = self._calc_line_and_column(text, caret_position)
self._start_editor(line=line, column=column)
diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py
index ad3f665b4..91bdce26b 100644
--- a/tests/unit/misc/test_editor.py
+++ b/tests/unit/misc/test_editor.py
@@ -73,14 +73,16 @@ class TestFileHandling:
"""Test creation/deletion of tempfile."""
- def test_ok(self, editor):
+ @pytest.mark.parametrize('remove_file', [True, False])
+ def test_ok(self, editor, remove_file, config_stub):
"""Test file handling when closing with an exit status == 0."""
+ config_stub.val.editor.remove_file = remove_file
editor.edit("")
filename = pathlib.Path(editor._filename)
assert filename.exists()
assert filename.name.startswith('qutebrowser-editor-')
editor._proc._proc.finished.emit(0, QProcess.NormalExit)
- assert not filename.exists()
+ assert filename.exists() != config_stub.val.editor.remove_file
@pytest.mark.parametrize('touch', [True, False])
def test_with_filename(self, editor, tmp_path, touch):