From 9a2dceeea1a799867bd658258397ed532727f9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Wed, 13 Mar 2024 12:19:31 +0800 Subject: [PATCH] windows: Support dropping targets with filenames longer than 260 characters (#9115) use `Vec` instead of slice to support dynamic filename length. Release Notes: - N/A --- crates/gpui/src/platform/windows/window.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 1caceef751..a4994f001c 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -22,7 +22,7 @@ use smallvec::SmallVec; use windows::{ core::{implement, w, HSTRING, PCWSTR}, Win32::{ - Foundation::{FALSE, HINSTANCE, HWND, LPARAM, LRESULT, MAX_PATH, POINTL, S_OK, WPARAM}, + Foundation::{FALSE, HINSTANCE, HWND, LPARAM, LRESULT, POINTL, S_OK, WPARAM}, Graphics::Gdi::{BeginPaint, EndPaint, InvalidateRect, PAINTSTRUCT}, System::{ Com::{IDataObject, DVASPECT_CONTENT, FORMATETC, TYMED_HGLOBAL}, @@ -983,9 +983,9 @@ impl IDropTarget_Impl for WindowsDragDropHandler { let hdrop = idata.u.hGlobal.0 as *mut HDROP; let file_count = DragQueryFileW(*hdrop, DRAGDROP_GET_FILES_COUNT, None); for file_index in 0..file_count { - let mut buffer = [0u16; MAX_PATH as _]; let filename_length = DragQueryFileW(*hdrop, file_index, None) as usize; - let ret = DragQueryFileW(*hdrop, file_index, Some(&mut buffer)); + let mut buffer = vec![0u16; filename_length + 1]; + let ret = DragQueryFileW(*hdrop, file_index, Some(buffer.as_mut_slice())); if ret == 0 { log::error!("unable to read file name"); continue;