Address code review: use < 2 condition, fix docstring, assert first handle = 2

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/6973699c-a979-4d97-8213-1a4a501044a1

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-10 07:39:40 +00:00
committed by GitHub
parent afa63ccec7
commit b8cbb7f68d
2 changed files with 5 additions and 2 deletions

View File

@@ -693,7 +693,7 @@ drop_alloc_dir_handle(Window *w, const char *path, char **entries, size_t num_en
w->drop.next_dir_handle_id++; w->drop.next_dir_handle_id++;
/* Handles 0 and 1 are reserved (0 = absent, 1 = symlink indicator), so /* Handles 0 and 1 are reserved (0 = absent, 1 = symlink indicator), so
* valid directory handles must be >= 2. */ * valid directory handles must be >= 2. */
if (w->drop.next_dir_handle_id <= 1) w->drop.next_dir_handle_id = 2; if (w->drop.next_dir_handle_id < 2) w->drop.next_dir_handle_id = 2;
DirHandle *h = &w->drop.dir_handles[w->drop.num_dir_handles++]; DirHandle *h = &w->drop.dir_handles[w->drop.num_dir_handles++];
zero_at_ptr(h); zero_at_ptr(h);
h->id = w->drop.next_dir_handle_id; h->id = w->drop.next_dir_handle_id;

View File

@@ -753,7 +753,7 @@ class TestDnDProtocol(BaseTest):
self.ae(events[0]['payload'].strip(), b'EINVAL') self.ae(events[0]['payload'].strip(), b'EINVAL')
def test_uri_directory_transfer_tree(self) -> None: def test_uri_directory_transfer_tree(self) -> None:
"""Full directory tree ( 3 levels deep) transfer: listing, sub-dirs, file integrity. """Full directory tree (>= 3 levels deep) transfer: listing, sub-dirs, file integrity.
Also verifies that every response from the terminal unambiguously Also verifies that every response from the terminal unambiguously
identifies the filesystem object it refers to. For sub-directory identifies the filesystem object it refers to. For sub-directory
@@ -2014,6 +2014,9 @@ class TestDnDProtocol(BaseTest):
self.ae(ev['meta'].get('y'), '1') self.ae(ev['meta'].get('y'), '1')
handle = dir_handle(ev) handle = dir_handle(ev)
self.assertGreater(handle, 1, 'X= must be a directory handle (> 1)') self.assertGreater(handle, 1, 'X= must be a directory handle (> 1)')
# In a fresh window the handle counter starts at 1, so the
# first allocated handle must be exactly 2.
self.ae(handle, 2, 'first allocated directory handle must be 2')
self.assertIsNone(ev['meta'].get('Y'), self.assertIsNone(ev['meta'].get('Y'),
'Y= must not be present in top-level dir response') 'Y= must not be present in top-level dir response')