internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: qutebrowser/qutebrowser

Issue:
:completion-item-yank breaks text copying
Selecting and copying something in the commandline doesn't work anymore now (as now completion item is selected).

I think `:completion-item-yank` should:

- Copy the selected text if there's a selection in the commandline (even if there's a completion item selected - though it seems doing so unselects things anyways)
- Copy the whole command if no completion item is selected and no text selection is there.

@rcorre what do you think?


Discussion:

Resolving patch:
diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py
--- a/qutebrowser/completion/completionwidget.py
+++ b/qutebrowser/completion/completionwidget.py
@@ -28,7 +28,7 @@
 
 from qutebrowser.config import config
 from qutebrowser.completion import completiondelegate
-from qutebrowser.utils import utils, usertypes, debug, log
+from qutebrowser.utils import utils, usertypes, debug, log, objreg
 from qutebrowser.commands import cmdexc, cmdutils
 
 
@@ -386,8 +386,12 @@ def completion_item_yank(self, sel=False):
         Args:
             sel: Use the primary selection instead of the clipboard.
         """
-        index = self.currentIndex()
-        if not index.isValid():
-            raise cmdexc.CommandError("No item selected!")
-        data = self.model().data(index)
-        utils.set_clipboard(data, selection=sel)
+        status = objreg.get('status-command', scope='window',
+                            window=self._win_id)
+        text = status.selectedText()
+        if not text:
+            index = self.currentIndex()
+            if not index.isValid():
+                raise cmdexc.CommandError("No item selected!")
+            text = self.model().data(index)
+        utils.set_clipboard(text, selection=sel)


Test patch:
diff --git a/tests/unit/completion/test_completionwidget.py b/tests/unit/completion/test_completionwidget.py
--- a/tests/unit/completion/test_completionwidget.py
+++ b/tests/unit/completion/test_completionwidget.py
@@ -262,6 +262,26 @@ def test_completion_item_yank(completionview, mocker, sel):
     m.set_clipboard.assert_called_once_with('foo', sel)
 
 
+@pytest.mark.parametrize('sel', [True, False])
+def test_completion_item_yank_selected(completionview, status_command_stub,
+                                       mocker, sel):
+    """Test that completion_item_yank yanks selected text."""
+    m = mocker.patch(
+        'qutebrowser.completion.completionwidget.utils',
+        autospec=True)
+    model = completionmodel.CompletionModel()
+    cat = listcategory.ListCategory('', [('foo', 'bar')])
+    model.add_category(cat)
+
+    completionview.set_model(model)
+    completionview.completion_item_focus('next')
+
+    status_command_stub.selectedText = mock.Mock(return_value='something')
+    completionview.completion_item_yank(sel)
+
+    m.set_clipboard.assert_called_once_with('something', sel)
+
+
 def test_resize_no_model(completionview, qtbot):
     """Ensure no crash if resizeEvent is triggered with no model (#2854)."""
     completionview.resizeEvent(None)
Repository: qutebrowser/qutebrowser

Issue:
Add --file for :debug-pyeval
Just like with `:jseval`, it'd be nice if `:debug-pyeval` had a `--file` to allow for multi-line code.


Discussion:

Resolving patch:
diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py
--- a/qutebrowser/misc/utilcmds.py
+++ b/qutebrowser/misc/utilcmds.py
@@ -229,18 +229,33 @@ def debug_trace(expr=""):
 
 
 @cmdutils.register(maxsplit=0, debug=True, no_cmd_split=True)
-def debug_pyeval(s, quiet=False):
+def debug_pyeval(s, file=False, quiet=False):
     """Evaluate a python string and display the results as a web page.
 
     Args:
         s: The string to evaluate.
+        file: Interpret s as a path to file, also implies --quiet.
         quiet: Don't show the output in a new tab.
     """
-    try:
-        r = eval(s)
-        out = repr(r)
-    except Exception:
-        out = traceback.format_exc()
+    if file:
+        quiet = True
+        path = os.path.expanduser(s)
+        try:
+            with open(path, 'r', encoding='utf-8') as f:
+                s = f.read()
+        except OSError as e:
+            raise cmdexc.CommandError(str(e))
+        try:
+            exec(s)
+            out = "No error"
+        except Exception:
+            out = traceback.format_exc()
+    else:
+        try:
+            r = eval(s)
+            out = repr(r)
+        except Exception:
+            out = traceback.format_exc()
 
     qutescheme.pyeval_output = out
     if quiet:


Test patch:
diff --git a/tests/end2end/data/misc/pyeval_file.py b/tests/end2end/data/misc/pyeval_file.py
new file mode 100644
--- /dev/null
+++ b/tests/end2end/data/misc/pyeval_file.py
@@ -0,0 +1,6 @@
+# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
+
+"""Simple test file for :debug-pyeval."""
+
+from qutebrowser.utils import message
+message.info("Hello World")
diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature
--- a/tests/end2end/features/qutescheme.feature
+++ b/tests/end2end/features/qutescheme.feature
@@ -171,6 +171,15 @@ Feature: Special qute:// pages
         And I wait until qute://pyeval/ is loaded
         Then the page should contain the plaintext "ZeroDivisionError"
 
+    Scenario: Running :pyveal with --file using a file that exists as python code
+        When I run :debug-pyeval --file (testdata)/misc/pyeval_file.py
+        Then the message "Hello World" should be shown
+        And "pyeval output: No error" should be logged
+
+    Scenario: Running :pyeval --file using a non existing file
+        When I run :debug-pyeval --file nonexistentfile
+        Then the error "[Errno 2] No such file or directory: 'nonexistentfile'" should be shown
+
     Scenario: Running :pyeval with --quiet
         When I run :debug-pyeval --quiet 1+1
         Then "pyeval output: 2" should be logged
Repository: qutebrowser/qutebrowser

Issue:
edit-command --run should clear the status bar
Thanks to @rcorre for implementing `:edit-command` from #2453. Quick issue: when using the `--run` flag, not only should the command be executed, but the status bar should also be cleared (or whatever `<esc>` tends to do). Here's what happens currently (v1.0.3, abb5c9f63):

- bind `<ctrl-e>` to `edit-command --run`
- do `:open<ctrl-e>`
- type `www.qutebrowser.org`
- save & quit

What happens:

1. get sent to the Qutebrowser home page
2. status bar still says `:open www.qutebrowser.org`, and I also see URLs from my history

What I expected to happen: 1 but not 2.

This means I need to hit `<esc>` after doing an `:edit-command --run`.


Discussion:

Resolving patch:
diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py
--- a/qutebrowser/mainwindow/statusbar/command.py
+++ b/qutebrowser/mainwindow/statusbar/command.py
@@ -178,7 +178,7 @@ def edit_command(self, run=False):
         def callback(text):
             self.set_cmd_text(text)
             if run:
-                self.got_cmd[str].emit(text)
+                self.command_accept()
 
         ed.editing_finished.connect(callback)
         ed.edit(self.text())


Test patch:
diff --git a/tests/end2end/features/editor.feature b/tests/end2end/features/editor.feature
--- a/tests/end2end/features/editor.feature
+++ b/tests/end2end/features/editor.feature
@@ -149,3 +149,4 @@ Feature: Opening external editors
         And I set up a fake editor replacing "foo" by "bar"
         And I run :edit-command --run
         Then the message "bar" should be shown
+        And "Leaving mode KeyMode.command (reason: cmd accept)" should be logged
Repository: qutebrowser/qutebrowser

Issue:
Retain browser mode (insert/passthrough) when switching tabs
<!-- If this is a bug report, please remember to mention your version info from
`:open qute:version` or `qutebrowser --version` -->



Discussion:
Should the mode be per tab or just global?
A per-tab mode seems unnecessarily complex to me.
There are cases where I'm writing something (in insert mode), but I have to switch tabs briefly to lookup a thing. Currently, when I switch back to the tab I'm writing in, I have to remember to go to insert mode. Sometimes it's easy to forget and typing in normal mode might have annoying or really bad behaviour (like pressing `d` or `r`).

I guess I should just be using external editor more.

Resolving patch:
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -652,9 +652,11 @@ def on_current_changed(self, idx):
 
         log.modes.debug("Current tab changed, focusing {!r}".format(tab))
         tab.setFocus()
-        for mode in [usertypes.KeyMode.hint, usertypes.KeyMode.insert,
-                     usertypes.KeyMode.caret, usertypes.KeyMode.passthrough]:
-            modeman.leave(self._win_id, mode, 'tab changed', maybe=True)
+        if not config.val.tabs.persist_mode_on_change:
+            for mode in [usertypes.KeyMode.hint, usertypes.KeyMode.insert,
+                         usertypes.KeyMode.caret,
+                         usertypes.KeyMode.passthrough]:
+                modeman.leave(self._win_id, mode, 'tab changed', maybe=True)
         if self._now_focused is not None:
             objreg.register('last-focused-tab', self._now_focused, update=True,
                             scope='window', window=self._win_id)


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
History completion by both URL and title
Currently the completion works by matching either URL or title, but not both. Sometimes it is useful to write the hostname and then part of the title to search within the results for the given server.

Desired use case:
1. start `qutebrowser --temp-basedir`
2. `:open https://github.com/The-Compiler/qutebrowser/issues/786` (followed by Enter)
3. `:open github history` (without Enter)
4. then the above URL should be matched



Discussion:
Sounds good to me - @toofar do you want to take a look by any chance as you added title completion?

@The-Compiler  Nope. No input from me sorry I am between proper computing devices at the moment.

This is working already in the current master.
No, not as described in the issue.

Resolving patch:
diff --git a/qutebrowser/completion/models/histcategory.py b/qutebrowser/completion/models/histcategory.py
--- a/qutebrowser/completion/models/histcategory.py
+++ b/qutebrowser/completion/models/histcategory.py
@@ -47,7 +47,7 @@ def __init__(self, *, delete_func=None, parent=None):
             "FROM CompletionHistory",
             # the incoming pattern will have literal % and _ escaped with '\'
             # we need to tell sql to treat '\' as an escape character
-            "WHERE (url LIKE :pat escape '\\' or title LIKE :pat escape '\\')",
+            "WHERE ((url || title) LIKE :pat escape '\\')",
             self._atime_expr(),
             "ORDER BY last_atime DESC",
         ]), forward_only=False)


Test patch:
diff --git a/tests/unit/completion/test_histcategory.py b/tests/unit/completion/test_histcategory.py
--- a/tests/unit/completion/test_histcategory.py
+++ b/tests/unit/completion/test_histcategory.py
@@ -78,6 +78,10 @@ def hist(init_sql, config_stub):
     ("can't",
      [("can't touch this", ''), ('a', '')],
      [("can't touch this", '')]),
+
+    ("ample itle",
+     [('example.com', 'title'), ('example.com', 'nope')],
+     [('example.com', 'title')]),
 ])
 def test_set_pattern(pattern, before, after, model_validator, hist):
     """Validate the filtering and sorting results of set_pattern."""
Repository: qutebrowser/qutebrowser

Issue:
Rapid firing for completion
The completion should have some way to spawn a completed command without closing the completion - for example, using <kbd>Shift-Enter</kbd> or middle-click.



Discussion:
This would be great for people like me who make lots of mistakes!


Resolving patch:
diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py
--- a/qutebrowser/mainwindow/statusbar/command.py
+++ b/qutebrowser/mainwindow/statusbar/command.py
@@ -156,8 +156,12 @@ def command_history_next(self):
 
     @cmdutils.register(instance='status-command',
                        modes=[usertypes.KeyMode.command], scope='window')
-    def command_accept(self):
-        """Execute the command currently in the commandline."""
+    def command_accept(self, rapid=False):
+        """Execute the command currently in the commandline.
+
+        Args:
+            rapid: Run the command without closing or clearing the command bar.
+        """
         prefixes = {
             ':': '',
             '/': 'search -- ',
@@ -165,7 +169,9 @@ def command_accept(self):
         }
         text = self.text()
         self.history.append(text)
-        modeman.leave(self._win_id, usertypes.KeyMode.command, 'cmd accept')
+        if not rapid:
+            modeman.leave(self._win_id, usertypes.KeyMode.command,
+                          'cmd accept')
         self.got_cmd[str].emit(prefixes[text[0]] + text[1:])
 
     @cmdutils.register(instance='status-command', scope='window')


Test patch:
diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature
--- a/tests/end2end/features/misc.feature
+++ b/tests/end2end/features/misc.feature
@@ -9,6 +9,13 @@ Feature: Various utility commands.
         And I run :command-accept
         Then the message "Hello World" should be shown
 
+    Scenario: :set-cmd-text and :command-accept --rapid
+        When I run :set-cmd-text :message-info "Hello World"
+        And I run :command-accept --rapid
+        And I run :command-accept
+        Then the message "Hello World" should be shown
+        And the message "Hello World" should be shown
+
     Scenario: :set-cmd-text with two commands
         When I run :set-cmd-text :message-info test ;; message-error error
         And I run :command-accept
Repository: qutebrowser/qutebrowser

Issue:
Different colors per completion column
I think it would present a lot of visual clarity to be able to style the completion list's “sections” separately.

For example in pentadactyl, I can very easily visually distinguish between URLs and URL titles based on color alone:

![pentadactyl](https://0x0.st/BbS.png)

I'm lacking this visual feedback in qutebrowser. I think as a rough first approximation it would be fine to give explicit colors to the Nth sections (regardless of what they are), but I think in principle for this to work as well as possible the section order would have to be somewhat consistent between commands (so the URL is always in the same place, the title is always in the same place, etc.)



Discussion:
Based on the screenshot, I guess you mean columns when you say sections?

Yes, exactly


Resolving patch:
diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py
--- a/qutebrowser/completion/completiondelegate.py
+++ b/qutebrowser/completion/completiondelegate.py
@@ -138,10 +138,10 @@ def _draw_text(self, index):
 
         self._painter.translate(text_rect.left(), text_rect.top())
         self._get_textdoc(index)
-        self._draw_textdoc(text_rect)
+        self._draw_textdoc(text_rect, index.column())
         self._painter.restore()
 
-    def _draw_textdoc(self, rect):
+    def _draw_textdoc(self, rect, col):
         """Draw the QTextDocument of an item.
 
         Args:
@@ -156,7 +156,9 @@ def _draw_textdoc(self, rect):
         elif not self._opt.state & QStyle.State_Enabled:
             color = config.val.colors.completion.category.fg
         else:
-            color = config.val.colors.completion.fg
+            colors = config.val.colors.completion.fg
+            # if multiple colors are set, use different colors per column
+            color = colors[col % len(colors)]
         self._painter.setPen(color)
 
         ctx = QAbstractTextDocumentLayout.PaintContext()


Test patch:
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -385,7 +385,7 @@ def test_get_opt_invalid(self, conf):
 
     def test_get(self, conf):
         """Test conf.get() with a QColor (where get/get_obj is different)."""
-        assert conf.get('colors.completion.fg') == QColor('white')
+        assert conf.get('colors.completion.category.fg') == QColor('white')
 
     @pytest.mark.parametrize('value', [{}, {'normal': {'a': 'nop'}}])
     def test_get_bindings(self, config_stub, conf, value):
@@ -400,7 +400,7 @@ def test_get_mutable(self, conf):
         assert not conf._mutables
 
     def test_get_obj_simple(self, conf):
-        assert conf.get_obj('colors.completion.fg') == 'white'
+        assert conf.get_obj('colors.completion.category.fg') == 'white'
 
     @pytest.mark.parametrize('option', ['content.headers.custom',
                                         'keyhint.blacklist',
Repository: qutebrowser/qutebrowser

Issue:
"Suspended" tabs in history
When `session.lazy_restore` is `true`, "qute://back/*" urls are included in the history. As re-opening such URLs is pointless, perhaps they should not be saved in the history.

"Suspended" tabs in history
When `session.lazy_restore` is `true`, "qute://back/*" urls are included in the history. As re-opening such URLs is pointless, perhaps they should not be saved in the history.



Discussion:
You mean when going back/forward? This probably would make sense indeed. @seebye do you want to take a look at this?
> You mean when going back/forward?

Yes.
For instance, `:open -t qute://back` displays useless suggestions (as we can go back anymore from such urls). This can leads to noisy history search results.
Should be fixed with: https://github.com/seebye/qutebrowser/commit/a911094846e438596e5a0656cf6f8f515eb3fd21
You mean when going back/forward? This probably would make sense indeed. @seebye do you want to take a look at this?
> You mean when going back/forward?

Yes.
For instance, `:open -t qute://back` displays useless suggestions (as we can go back anymore from such urls). This can leads to noisy history search results.
Should be fixed with: https://github.com/seebye/qutebrowser/commit/a911094846e438596e5a0656cf6f8f515eb3fd21

Resolving patch:
diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py
--- a/qutebrowser/browser/history.py
+++ b/qutebrowser/browser/history.py
@@ -32,7 +32,7 @@
 
 
 # increment to indicate that HistoryCompletion must be regenerated
-_USER_VERSION = 1
+_USER_VERSION = 2
 
 
 class CompletionHistory(sql.SqlTable):
@@ -102,7 +102,8 @@ def _rebuild_completion(self):
         data = {'url': [], 'title': [], 'last_atime': []}
         # select the latest entry for each url
         q = sql.Query('SELECT url, title, max(atime) AS atime FROM History '
-                      'WHERE NOT redirect GROUP BY url ORDER BY atime asc')
+                      'WHERE NOT redirect and url NOT LIKE "qute://back%" '
+                      'GROUP BY url ORDER BY atime asc')
         for entry in q.run():
             data['url'].append(self._format_completion_url(QUrl(entry.url)))
             data['title'].append(entry.title)
@@ -171,7 +172,9 @@ def delete_url(self, url):
     @pyqtSlot(QUrl, QUrl, str)
     def add_from_tab(self, url, requested_url, title):
         """Add a new history entry as slot, called from a BrowserTab."""
-        if url.scheme() == 'data' or requested_url.scheme() == 'data':
+        if any(url.scheme() == 'data' or
+               (url.scheme(), url.host()) == ('qute', 'back')
+               for url in (url, requested_url)):
             return
         if url.isEmpty():
             # things set via setHtml


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
Doing :-w open crashes
When typing `:-w open ` (with trailing space):

```
17:56:49 DEBUG    completion completer:_partition:141 partitioning ['-w', ' open', ' '] around position 8
17:56:49 DEBUG    completion completer:_partition:153 partitioned: ['-w', 'open'] '' []
17:56:49 DEBUG    completion completer:_update_completion:236 Updating completion: ['-w', 'open']  []
17:56:49 DEBUG    completion completer:_get_new_completion:89 Before removing flags: ['-w', 'open']
17:56:49 DEBUG    completion completer:_get_new_completion:91 After removing flags: ['open']
17:56:49 DEBUG    completion debug:__exit__:264 Starting url completion took 6.5e-05 seconds.
17:56:49 ERROR    misc       crashsignal:exception_hook:216 Uncaught exception
Traceback (most recent call last):
  File "/home/florian/proj/qutebrowser/git/qutebrowser/completion/completer.py", line 255, in _update_completion
    model = func(*args, info=info)
TypeError: url() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given
```

cc @rcorre 


Discussion:

Resolving patch:
diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py
--- a/qutebrowser/completion/completer.py
+++ b/qutebrowser/completion/completer.py
@@ -87,8 +87,6 @@ def _get_new_completion(self, before_cursor, under_cursor):
             # cursor on a flag or after an explicit split (--)
             return None
         log.completion.debug("Before removing flags: {}".format(before_cursor))
-        before_cursor = [x for x in before_cursor if not x.startswith('-')]
-        log.completion.debug("After removing flags: {}".format(before_cursor))
         if not before_cursor:
             # '|' or 'set|'
             log.completion.debug('Starting command completion')
@@ -99,6 +97,9 @@ def _get_new_completion(self, before_cursor, under_cursor):
             log.completion.debug("No completion for unknown command: {}"
                                  .format(before_cursor[0]))
             return None
+
+        before_cursor = [x for x in before_cursor if not x.startswith('-')]
+        log.completion.debug("After removing flags: {}".format(before_cursor))
         argpos = len(before_cursor) - 1
         try:
             func = cmd.get_pos_arg_info(argpos).completion


Test patch:
diff --git a/tests/unit/completion/test_completer.py b/tests/unit/completion/test_completer.py
--- a/tests/unit/completion/test_completer.py
+++ b/tests/unit/completion/test_completer.py
@@ -190,6 +190,7 @@ def _set_cmd_prompt(cmd, txt):
     (':gibberish nonesense |', None, '', []),
     ('/:help|', None, '', []),
     ('::bind|', 'command', ':bind', []),
+    (':-w open |', None, '', []),
 ])
 def test_update_completion(txt, kind, pattern, pos_args, status_command_stub,
                            completer_obj, completion_widget_stub, config_stub,