)]}'
{
  "commit": "2bebc9ee2708086cec6c8dfd256c91184357ed2f",
  "tree": "fa1d747d870aa14e1c0ae81cdd8158a2972286e6",
  "parents": [
    "bbbfe4af4fb5bc246a6cb15e95f29a3cd05e9145"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Feb 22 14:56:43 2024 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Sat Sep 07 20:28:58 2024 +0100"
  },
  "message": "gdb: add match formatter mechanism for \u0027complete\u0027 command output\n\nThis commit solves a problem that existed prior to the previous\ncommit, but the previous commit made more common.\n\nWhen completing a filename with the \u0027complete\u0027 command GDB will always\nadd a trailing quote character, even if the completion is a directory\nname, in which case it would be better if the trailing quote was not\nadded.  Consider:\n\n  (gdb) complete file \u0027/tmp/xx\n  file \u0027/tmp/xxx/\u0027\n\nThe completion offered here is really only a partial completion, we\u0027ve\ncompleted up to the end of the next directory name, but, until we have\na filename then the completion is not finished and the trailing quote\nshould not be added.\n\nThis would match the readline behaviour, e.g.:\n\n  (gdb) file \u0027/tmp/xx\u003cTAB\u003e\n  (gdb) file \u0027/tmp/xxx/\n\nIn this case readline completes the directory name, but doesn\u0027t add\nthe trailing quote character.\n\nRemember that the \u0027complete\u0027 command is intended for tools like\ne.g. emacs in order that they can emulate GDB\u0027s standard readline\ncompletion when implementing a CLI of their own.  As such, not adding\nthe trailing quote in this case matches the readline behaviour, and\nseems like the right way to go.\n\nTo achieve this, I\u0027ve added a new function pointer member variable\ncompletion_result::m_match_formatter.  This contains a pointer to a\ncallback function which is used by the \u0027complete\u0027 command to format\neach result.\n\nThe default behaviour of this callback function is to just append the\nquote character (the character from before the completion string) to\nthe end of the completion result.  This matches the current behaviour.\n\nHowever, for filename completion we override the default value of\nm_match_formatter, this new function checks if the completion result\nis a directory or not.  If the completion result is a directory then\nthe closing quote is not added, instead we add a trailing \u0027/\u0027\ncharacter.\n\nThe code to add a trailing \u0027/\u0027 character already exists within the\nfilename_completer function.  This is no longer needed in this\nlocation, instead this code is moved into the formatter callback.\n\nTests are updated to handle the changes in functionality, this removes\nan xfail added in the previous commit.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2793ce600b98002f4c63ff235ef95dd929b748bd",
      "old_mode": 33188,
      "old_path": "gdb/completer.c",
      "new_id": "d9123e6e74a31603fad01584738a862e7890cda6",
      "new_mode": 33188,
      "new_path": "gdb/completer.c"
    },
    {
      "type": "modify",
      "old_id": "e6dc9417932b24e8c18b67a7fca03e509a486af7",
      "old_mode": 33188,
      "old_path": "gdb/completer.h",
      "new_id": "c18bd16ad26d0266beca44f4d265d4bf9fee3037",
      "new_mode": 33188,
      "new_path": "gdb/completer.h"
    },
    {
      "type": "modify",
      "old_id": "e8acd2f85cf0cd0cc273a2b066f97edf173f9bdc",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/filename-completion.exp",
      "new_id": "39f616b45ba28eaea800478949b9244485a03017",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/filename-completion.exp"
    }
  ]
}
