summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-03-31 13:26:31 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-03-31 13:26:31 +0200
commitd68357f16c1109bcaf177e7774b9e4201bb9e8be (patch)
tree6d4eac7e9764a1e5e80db2a799cb33f5f6b50079
parent3646d1330034ea9f81be8997900631c9d6a81ea9 (diff)
parent3cbb7194b0cd26819e1452df0f773bc21c4b4737 (diff)
downloadqutebrowser-d68357f16c1109bcaf177e7774b9e4201bb9e8be.tar.gz
qutebrowser-d68357f16c1109bcaf177e7774b9e4201bb9e8be.zip
Merge remote-tracking branch 'origin/pr/7010'
-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):