Skip to content

fix(drag-drop): IDM 拖拽问题#2711

Draft
LinQingYuu wants to merge 12 commits intodevfrom
fix/idm-drop
Draft

fix(drag-drop): IDM 拖拽问题#2711
LinQingYuu wants to merge 12 commits intodevfrom
fix/idm-drop

Conversation

@LinQingYuu
Copy link
Copy Markdown
Member

@LinQingYuu LinQingYuu commented Apr 15, 2026

Resolve #2220

Summary by Sourcery

调整拖放处理方式,以正确识别 IDM 风格的文件拖放,以及基于文本的文件路径或 URI。

Bug 修复:

  • 在同时存在文件拖放数据和文本数据时,优先使用文件拖放数据,以便在有文件参与拖动时能够正确识别并映射为链接效果。
  • 确保表示特定 URI scheme 或文件路径的文本拖放数据(包括没有 file:/// 前缀的纯文件路径)能够正确触发复制效果,而不是被忽略或错误处理。
Original summary in English

Summary by Sourcery

Adjust drag-and-drop handling to correctly recognize IDM-style file drops and text-based file paths or URIs.

Bug Fixes:

  • Prioritize file-drop data over text data so that file drags are recognized and mapped to link effects when files are present.
  • Ensure text drag data representing specific URI schemes or file paths, including plain paths without a file:/// prefix, correctly trigger copy effects instead of being ignored or mishandled.

Summary by Sourcery

改进拖放处理,以正确解析文件拖放以及基于文本的文件路径或 URI。

Bug 修复:

  • 优先使用文件拖放数据而不是文本数据,这样在存在文件时,文件拖动可以稳定地被视为链接拖放。
  • 安全处理文本拖动数据,将以根路径开头的文件路径和类 URI 字符串识别为复制操作,而不是忽略或错误分类。

增强功能:

  • 在拖放逻辑中统一对纯文件路径和文件拖放数据的处理,以获得更一致的行为。
Original summary in English

Summary by Sourcery

Improve drag-and-drop handling to correctly interpret file drops and text-based file paths or URIs.

Bug Fixes:

  • Prioritize file-drop data over text data so file drags are reliably treated as link drops when files are present.
  • Safely handle text drag data and recognize rooted file paths and URI-like strings as copy operations instead of ignoring or misclassifying them.

Enhancements:

  • Unify handling of plain file paths and file-drop data in drag-and-drop logic for more consistent behavior.

Bug 修复:

  • 使文件拖放数据优先于文本数据,这样在存在文件时,文件拖动会被正确视为链接拖放。
  • 更稳健地处理文本拖动数据,包括空安全类型转换,从而使类 URI 字符串和带根路径的文件路径能够可靠地触发复制效果,而不是被忽略。
Original summary in English

Summary by Sourcery

改进拖放处理,以正确解析文件拖放以及基于文本的文件路径或 URI。

Bug 修复:

  • 优先使用文件拖放数据而不是文本数据,这样在存在文件时,文件拖动可以稳定地被视为链接拖放。
  • 安全处理文本拖动数据,将以根路径开头的文件路径和类 URI 字符串识别为复制操作,而不是忽略或错误分类。

增强功能:

  • 在拖放逻辑中统一对纯文件路径和文件拖放数据的处理,以获得更一致的行为。
Original summary in English

Summary by Sourcery

Improve drag-and-drop handling to correctly interpret file drops and text-based file paths or URIs.

Bug Fixes:

  • Prioritize file-drop data over text data so file drags are reliably treated as link drops when files are present.
  • Safely handle text drag data and recognize rooted file paths and URI-like strings as copy operations instead of ignoring or misclassifying them.

Enhancements:

  • Unify handling of plain file paths and file-drop data in drag-and-drop logic for more consistent behavior.

@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: S PR 大小评估:小型 labels Apr 15, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 15, 2026

Reviewer's Guide

调整 FormMain.xaml.vb 中的拖放处理逻辑,使其在判定拖拽类型时优先使用文件拖放数据而不是文本数据,更健壮地处理基于文本的 URI 和文件路径(包括没有 file:/// 前缀但已根路径的路径),并添加空安全的类型转换以及统一文件处理流程,让文件拖放和纯路径拖放走同一套逻辑。

FormMain 中更新后的 DragEnter 处理流程图

flowchart TD
    DragEnterStart["DragEnter handler start"]
    CheckPrevData["Check PrevData and e.Data equality"]
    ReturnPrevEffects["Set e.Effects to PrevEffects and return"]

    InitEffects["Set e.Effects to None"]
    SavePrevData["PrevData = e.Data"]

    CheckFileDrop["e.Data.GetDataPresent(FileDrop)?"]
    GetFiles["Files = e.Data.GetData(FileDrop)"]
    FilesNotEmpty["Files not null and length > 0?"]
    SetLinkEffect["Set e.Effects to Link"]

    CheckText["e.Data.GetDataPresent(Text)?"]
    GetText["Str = TryCast(e.Data.GetData(Text), String)"]
    TextNull["Str is null?"]

    CheckAuthlib["Str.StartsWithF(authlib-injector:yggdrasil-server:)?"]
    CheckFileUri["Str.StartsWithF(file:///)?"]
    CheckRootedPath["Path.IsPathRooted(Str)?"]
    SetCopyEffect["Set e.Effects to Copy"]

    SavePrevEffects["PrevEffects = e.Effects"]
    LogEffect["Log drag effect"]
    EndDragEnter["DragEnter handler end"]

    DragEnterStart --> CheckPrevData
    CheckPrevData -- equal --> ReturnPrevEffects
    CheckPrevData -- not equal --> InitEffects

    InitEffects --> SavePrevData
    SavePrevData --> CheckFileDrop

    CheckFileDrop -- yes --> GetFiles
    GetFiles --> FilesNotEmpty
    FilesNotEmpty -- yes --> SetLinkEffect
    FilesNotEmpty -- no --> CheckText

    CheckFileDrop -- no --> CheckText

    CheckText -- no --> SavePrevEffects
    CheckText -- yes --> GetText

    GetText --> TextNull
    TextNull -- yes --> SavePrevEffects
    TextNull -- no --> CheckAuthlib

    CheckAuthlib -- yes --> SetCopyEffect
    CheckAuthlib -- no --> CheckFileUri

    CheckFileUri -- yes --> SetCopyEffect
    CheckFileUri -- no --> CheckRootedPath

    CheckRootedPath -- yes --> SetCopyEffect
    CheckRootedPath -- no --> SavePrevEffects

    SetCopyEffect --> SavePrevEffects
    SetLinkEffect --> SavePrevEffects

    SavePrevEffects --> LogEffect
    LogEffect --> EndDragEnter
Loading

FormMain 中更新后的 Drop 处理流程图

flowchart TD
    DropStart["Drop handler start"]

    CheckTextPresent["e.Data.GetDataPresent(Text)?"]
    GetDropText["Str = TryCast(e.Data.GetData(Text), String)"]
    TextNullDrop["Str is null?"]
    LogTextDrop["Log accepted text drag"]
    CheckRootedPathDrop["Path.IsPathRooted(Str)?"]
    GoToPathText["Jump to PathText branch"]

    CheckAuthlibDrop["Str.StartsWithF(authlib-injector:yggdrasil-server:)?"]
    HandleAuthlib["Handle authlib injector drop"]

    CheckFileUriDrop["Str.StartsWithF(file:///)?"]
    HandleFileUriText["Handle file:/// URI text drop"]

    CheckFileDropPresent["e.Data.GetDataPresent(FileDrop)?"]
    PathText["PathText: unified file handling entry"]
    GetFileDrop["FilePathRaw = e.Data.GetData(FileDrop)"]
    CheckFilePathRaw["FilePathRaw is null?"]
    HandleFileDrop["Handle file(s) or path(s) drop"]

    EndDrop["Drop handler end"]

    DropStart --> CheckTextPresent

    CheckTextPresent -- yes --> GetDropText
    CheckTextPresent -- no --> CheckFileDropPresent

    GetDropText --> TextNullDrop
    TextNullDrop -- yes --> EndDrop
    TextNullDrop -- no --> LogTextDrop

    LogTextDrop --> CheckRootedPathDrop

    CheckRootedPathDrop -- yes --> GoToPathText
    CheckRootedPathDrop -- no --> CheckAuthlibDrop

    CheckAuthlibDrop -- yes --> HandleAuthlib
    CheckAuthlibDrop -- no --> CheckFileUriDrop

    CheckFileUriDrop -- yes --> HandleFileUriText
    CheckFileUriDrop -- no --> EndDrop

    HandleAuthlib --> EndDrop
    HandleFileUriText --> EndDrop

    CheckFileDropPresent -- yes --> PathText
    CheckFileDropPresent -- no --> EndDrop

    GoToPathText --> PathText

    PathText --> GetFileDrop
    GetFileDrop --> CheckFilePathRaw

    CheckFilePathRaw -- yes --> EndDrop
    CheckFilePathRaw -- no --> HandleFileDrop

    HandleFileDrop --> EndDrop
Loading

文件级变更说明

Change Details Files
在确定拖拽效果时优先使用文件拖放数据而不是文本数据,并更早持久化拖拽数据。
  • 在计算拖拽效果之前而不是之后,从当前拖拽事件的数据中设置 PrevData
  • 将拖拽效果初始化为 None,并优先检查 FileDrop,将非空文件数组映射为 Link 效果
  • 仅在不存在 FileDrop 时才回退使用文本数据
Plain Craft Launcher 2/FormMain.xaml.vb
提高基于文本的 URI 和文件路径拖拽处理的健壮性和覆盖范围。
  • 在获取文本数据时使用 TryCast,以避免无效类型转换和空引用问题
  • 在进一步处理前对文本是否为空进行检查
  • 在现有 authlib-injectorfile:/// URI 检查基础上,使用 Path.IsPathRooted 将复制效果的判定扩展到已根路径的文件系统路径
Plain Craft Launcher 2/FormMain.xaml.vb
在 Drop 事件中将路径样式的文本拖拽与文件拖放处理统一。
  • 在文本拖拽中检测根路径字符串,并通过 GoTo 标签将其路由到与 FileDrop 相同的代码路径
  • 引入 PathText 标签,使其在根路径文本和 FileDrop 处理之间共享
  • 对 IDM 风格的路径文本和标准 FileDrop 数据复用同一套 FileDrop 处理逻辑
Plain Craft Launcher 2/FormMain.xaml.vb

与关联 Issue 的对照评估

Issue Objective Addressed Explanation
#2220 允许用户通过将 IDM 下载完成对话框中的拖拽按钮拖到启动器上来安装整合包/模组包文件,并能够正确识别拖拽数据,将其视为可用于安装的有效文件/路径。

提示与命令

与 Sourcery 交互

  • 触发一次新的审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在某条审查评论下回复,请 Sourcery 根据该评论创建一个 Issue。你也可以直接回复 @sourcery-ai issue 来从该评论创建 Issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文任意位置写上 @sourcery-ai summary,即可在该位置生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 一次性解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve 来将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这非常有用。
  • 撤销所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss 来撤销所有现有的 Sourcery 审查。若你希望从一次全新的审查开始,尤其有用——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

前往你的 控制面板 以:

  • 启用或禁用诸如 Sourcery 自动生成的 Pull Request 摘要、审查者指南等审查特性。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查指令。
  • 调整其他审查相关设置。

获取帮助

Original review guide in English

Reviewer's Guide

Adjusts drag-and-drop handling in FormMain.xaml.vb to prioritize file-drop data over text data, robustly handle text-based URIs and file paths (including rooted paths without file:///), and add null-safe casting and shared file handling flow for both file-drop and plain-path drags.

Flow diagram for updated DragEnter handling in FormMain

flowchart TD
    DragEnterStart["DragEnter handler start"]
    CheckPrevData["Check PrevData and e.Data equality"]
    ReturnPrevEffects["Set e.Effects to PrevEffects and return"]

    InitEffects["Set e.Effects to None"]
    SavePrevData["PrevData = e.Data"]

    CheckFileDrop["e.Data.GetDataPresent(FileDrop)?"]
    GetFiles["Files = e.Data.GetData(FileDrop)"]
    FilesNotEmpty["Files not null and length > 0?"]
    SetLinkEffect["Set e.Effects to Link"]

    CheckText["e.Data.GetDataPresent(Text)?"]
    GetText["Str = TryCast(e.Data.GetData(Text), String)"]
    TextNull["Str is null?"]

    CheckAuthlib["Str.StartsWithF(authlib-injector:yggdrasil-server:)?"]
    CheckFileUri["Str.StartsWithF(file:///)?"]
    CheckRootedPath["Path.IsPathRooted(Str)?"]
    SetCopyEffect["Set e.Effects to Copy"]

    SavePrevEffects["PrevEffects = e.Effects"]
    LogEffect["Log drag effect"]
    EndDragEnter["DragEnter handler end"]

    DragEnterStart --> CheckPrevData
    CheckPrevData -- equal --> ReturnPrevEffects
    CheckPrevData -- not equal --> InitEffects

    InitEffects --> SavePrevData
    SavePrevData --> CheckFileDrop

    CheckFileDrop -- yes --> GetFiles
    GetFiles --> FilesNotEmpty
    FilesNotEmpty -- yes --> SetLinkEffect
    FilesNotEmpty -- no --> CheckText

    CheckFileDrop -- no --> CheckText

    CheckText -- no --> SavePrevEffects
    CheckText -- yes --> GetText

    GetText --> TextNull
    TextNull -- yes --> SavePrevEffects
    TextNull -- no --> CheckAuthlib

    CheckAuthlib -- yes --> SetCopyEffect
    CheckAuthlib -- no --> CheckFileUri

    CheckFileUri -- yes --> SetCopyEffect
    CheckFileUri -- no --> CheckRootedPath

    CheckRootedPath -- yes --> SetCopyEffect
    CheckRootedPath -- no --> SavePrevEffects

    SetCopyEffect --> SavePrevEffects
    SetLinkEffect --> SavePrevEffects

    SavePrevEffects --> LogEffect
    LogEffect --> EndDragEnter
Loading

Flow diagram for updated Drop handling in FormMain

flowchart TD
    DropStart["Drop handler start"]

    CheckTextPresent["e.Data.GetDataPresent(Text)?"]
    GetDropText["Str = TryCast(e.Data.GetData(Text), String)"]
    TextNullDrop["Str is null?"]
    LogTextDrop["Log accepted text drag"]
    CheckRootedPathDrop["Path.IsPathRooted(Str)?"]
    GoToPathText["Jump to PathText branch"]

    CheckAuthlibDrop["Str.StartsWithF(authlib-injector:yggdrasil-server:)?"]
    HandleAuthlib["Handle authlib injector drop"]

    CheckFileUriDrop["Str.StartsWithF(file:///)?"]
    HandleFileUriText["Handle file:/// URI text drop"]

    CheckFileDropPresent["e.Data.GetDataPresent(FileDrop)?"]
    PathText["PathText: unified file handling entry"]
    GetFileDrop["FilePathRaw = e.Data.GetData(FileDrop)"]
    CheckFilePathRaw["FilePathRaw is null?"]
    HandleFileDrop["Handle file(s) or path(s) drop"]

    EndDrop["Drop handler end"]

    DropStart --> CheckTextPresent

    CheckTextPresent -- yes --> GetDropText
    CheckTextPresent -- no --> CheckFileDropPresent

    GetDropText --> TextNullDrop
    TextNullDrop -- yes --> EndDrop
    TextNullDrop -- no --> LogTextDrop

    LogTextDrop --> CheckRootedPathDrop

    CheckRootedPathDrop -- yes --> GoToPathText
    CheckRootedPathDrop -- no --> CheckAuthlibDrop

    CheckAuthlibDrop -- yes --> HandleAuthlib
    CheckAuthlibDrop -- no --> CheckFileUriDrop

    CheckFileUriDrop -- yes --> HandleFileUriText
    CheckFileUriDrop -- no --> EndDrop

    HandleAuthlib --> EndDrop
    HandleFileUriText --> EndDrop

    CheckFileDropPresent -- yes --> PathText
    CheckFileDropPresent -- no --> EndDrop

    GoToPathText --> PathText

    PathText --> GetFileDrop
    GetFileDrop --> CheckFilePathRaw

    CheckFilePathRaw -- yes --> EndDrop
    CheckFilePathRaw -- no --> HandleFileDrop

    HandleFileDrop --> EndDrop
Loading

File-Level Changes

Change Details Files
Prioritize file-drop data over text data when determining drag effects and persist drag data earlier.
  • Set PrevData from the drag event data before computing effects instead of after
  • Initialize drag effects to None and first check for FileDrop, mapping non-empty file arrays to Link effect
  • Use text data only as a fallback when FileDrop is not present
Plain Craft Launcher 2/FormMain.xaml.vb
Improve robustness and coverage of text drag handling for URIs and file paths.
  • Use TryCast when retrieving text data to avoid invalid casts and null issues
  • Guard against null text values before further processing
  • Extend copy-effect detection to rooted file-system paths via Path.IsPathRooted in addition to existing authlib-injector and file:/// URI checks
Plain Craft Launcher 2/FormMain.xaml.vb
Unify handling path-looking text drops with file-drop handling in Drop event.
  • Detect rooted path strings in text drops and route them through the same code path as FileDrop using a GoTo label
  • Introduce a PathText label that is shared between rooted-text and FileDrop handling
  • Reuse existing FileDrop processing logic for both IDM-style path text and standard FileDrop data
Plain Craft Launcher 2/FormMain.xaml.vb

Assessment against linked issues

Issue Objective Addressed Explanation
#2220 Allow users to install integration/modpack files by dragging the IDM download-complete dialog’s drag button onto the launcher, correctly recognizing the dragged data and treating it as a valid file/path for installation.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体性的反馈:

  • 当使用 e.Data.GetData(DataFormats.Text) 获取文本时,建议在调用字符串方法或 File.Exists 之前,使用 TryCast 并进行空检查,以避免当数据实际上不是字符串时出现潜在的无效类型转换异常。
  • 在调用 File.Exists(Str) 之前,建议先对文本进行规范化/校验(例如修剪空白字符,或检查 Path.IsPathRooted),这样可以减少任意文本内容触发不必要文件系统查询的可能性。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- When retrieving text with `e.Data.GetData(DataFormats.Text)`, consider using `TryCast` and a null check before calling string methods or `File.Exists` to avoid potential invalid-cast exceptions if the data is not actually a string.
- Before calling `File.Exists(Str)`, consider normalizing/validating the text (e.g., trimming whitespace or checking `Path.IsPathRooted`) so that arbitrary text payloads are less likely to trigger unnecessary filesystem lookups.

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查对你有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • When retrieving text with e.Data.GetData(DataFormats.Text), consider using TryCast and a null check before calling string methods or File.Exists to avoid potential invalid-cast exceptions if the data is not actually a string.
  • Before calling File.Exists(Str), consider normalizing/validating the text (e.g., trimming whitespace or checking Path.IsPathRooted) so that arbitrary text payloads are less likely to trigger unnecessary filesystem lookups.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When retrieving text with `e.Data.GetData(DataFormats.Text)`, consider using `TryCast` and a null check before calling string methods or `File.Exists` to avoid potential invalid-cast exceptions if the data is not actually a string.
- Before calling `File.Exists(Str)`, consider normalizing/validating the text (e.g., trimming whitespace or checking `Path.IsPathRooted`) so that arbitrary text payloads are less likely to trigger unnecessary filesystem lookups.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出一些整体反馈:

  • DragEnter 逻辑中,当 Str Is Nothing 时提前返回,会导致这一事件路径中不再设置 PrevData,从而改变了之前的行为;建议保持该处理函数的控制流一致,在合适的情况下始终更新 PrevData
  • 在文本负载上新增的 File.Exists(Str) 检查,可能会为任意拖入的文本引入额外的文件系统查询;建议对这一分支加以约束(例如仅针对看起来像路径的模式),或尽快短路返回,以避免在频繁拖拽时产生不必要的 IO。
给 AI 代理的提示
请根据本次代码评审中的评论进行修改:

## 总体评论
-`DragEnter` 逻辑中,当 `Str Is Nothing` 时提前返回,会导致这一事件路径中不再设置 `PrevData`,从而改变了之前的行为;建议保持该处理函数的控制流一致,在合适的情况下始终更新 `PrevData`- 在文本负载上新增的 `File.Exists(Str)` 检查,可能会为任意拖入的文本引入额外的文件系统查询;建议对这一分支加以约束(例如仅针对看起来像路径的模式),或尽快短路返回,以避免在频繁拖拽时产生不必要的 IO。

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • In the DragEnter logic, returning early when Str Is Nothing means PrevData is no longer set for this event path, which changes previous behavior; consider keeping the handler's control flow consistent so PrevData is always updated when appropriate.
  • The added File.Exists(Str) check on text payloads may introduce extra file system lookups for arbitrary drag text; consider constraining this branch (e.g., only for plausible path patterns) or short‑circuiting quickly to avoid unnecessary IO on frequent drags.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the `DragEnter` logic, returning early when `Str Is Nothing` means `PrevData` is no longer set for this event path, which changes previous behavior; consider keeping the handler's control flow consistent so `PrevData` is always updated when appropriate.
- The added `File.Exists(Str)` check on text payloads may introduce extra file system lookups for arbitrary drag text; consider constraining this branch (e.g., only for plausible path patterns) or short‑circuiting quickly to avoid unnecessary IO on frequent drags.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体性的反馈:

  • 在新的 text 分支中,If Str Is Nothing Then Return PrevData = e.Data 这行代码会导致后面的 PrevData 赋值语句永远无法执行;如果你希望在这种情况下保留 PrevData,请在 Return 之前设置它,或者移除 Return 之后的那条赋值语句。
  • 条件 ElseIf Str.Contains(":\") OrElse Str.Contains("\") AndAlso File.Exists(Str) 依赖 VB 的运算符优先级;建议添加括号,明确预期的分组方式,以避免未来被误解。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In the new text branch, `If Str Is Nothing Then Return PrevData = e.Data` makes the `PrevData` assignment unreachable; if you intend to preserve `PrevData` for this case, set it before returning or remove the assignment after `Return`.
- The `ElseIf Str.Contains(":\") OrElse Str.Contains("\") AndAlso File.Exists(Str)` condition relies on VB operator precedence; consider adding parentheses to make the intended grouping explicit and avoid future misinterpretation.

Sourcery 对开源项目永久免费——如果你喜欢我们的代码审查,请考虑分享给他人 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • In the new text branch, If Str Is Nothing Then Return PrevData = e.Data makes the PrevData assignment unreachable; if you intend to preserve PrevData for this case, set it before returning or remove the assignment after Return.
  • The ElseIf Str.Contains(":\") OrElse Str.Contains("\") AndAlso File.Exists(Str) condition relies on VB operator precedence; consider adding parentheses to make the intended grouping explicit and avoid future misinterpretation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the new text branch, `If Str Is Nothing Then Return PrevData = e.Data` makes the `PrevData` assignment unreachable; if you intend to preserve `PrevData` for this case, set it before returning or remove the assignment after `Return`.
- The `ElseIf Str.Contains(":\") OrElse Str.Contains("\") AndAlso File.Exists(Str)` condition relies on VB operator precedence; consider adding parentheses to make the intended grouping explicit and avoid future misinterpretation.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出一些整体性的反馈:

  • 在文本分支中检测普通文件路径时,建议使用 Path.IsPathRooted(Str)(并且可以考虑检查 URI scheme),而不是使用 Str.Contains(":\") OrElse Str.Contains("\"),以避免误报,并让路径检测在不同路径格式下都更加健壮。
  • 在处理 DataFormats.Text 时,当 StrNothing 时你现在会提前返回而不更新 PrevData;如果 PrevData 会被用于后续比较,建议在返回前先更新它,以保持与其他分支一致的行为。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- For detecting plain file paths in the text branch, consider using `Path.IsPathRooted(Str)` (and possibly checking for URI schemes) instead of `Str.Contains(":\") OrElse Str.Contains("\")` to avoid false positives and make path detection more robust across different path formats.
- In the `DataFormats.Text` handling, when `Str` is `Nothing` you now early-return without updating `PrevData`; if `PrevData` is used for later comparisons, you may want to set it before returning to keep behavior consistent with the other branches.

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • For detecting plain file paths in the text branch, consider using Path.IsPathRooted(Str) (and possibly checking for URI schemes) instead of Str.Contains(":\") OrElse Str.Contains("\") to avoid false positives and make path detection more robust across different path formats.
  • In the DataFormats.Text handling, when Str is Nothing you now early-return without updating PrevData; if PrevData is used for later comparisons, you may want to set it before returning to keep behavior consistent with the other branches.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- For detecting plain file paths in the text branch, consider using `Path.IsPathRooted(Str)` (and possibly checking for URI schemes) instead of `Str.Contains(":\") OrElse Str.Contains("\")` to avoid false positives and make path detection more robust across different path formats.
- In the `DataFormats.Text` handling, when `Str` is `Nothing` you now early-return without updating `PrevData`; if `PrevData` is used for later comparisons, you may want to set it before returning to keep behavior consistent with the other branches.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LinQingYuu LinQingYuu requested a review from a team April 15, 2026 08:28
@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai dismiss

@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些高层次的反馈:

  • DragOver 期间调用 File.Exists 可能会引入明显的 UI 延迟,尤其是针对 UNC 或网络路径时;可以考虑放宽为仅做语法层面的路径检查(例如:是否为根路径 / 扩展名是否有效),并把真正的存在性检查推迟到 drop 处理程序中再进行。
  • 目前的文本路径检测会将任何根路径或以 \\ 开头的字符串都视为路径;你可能需要进一步收紧判断条件(比如通过 Uri.TryCreate 或简单的模式匹配)以避免把任意文本误判为文件路径,从而意外改变拖拽时的效果。
面向 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Calling `File.Exists` during `DragOver` can introduce noticeable UI latency, especially for UNC or network paths; consider relaxing this to a syntactic path check (e.g., rooted path / valid extension) and deferring existence checks to the drop handler.
- The text-path detection currently treats any rooted or `\\`-prefixed string as a path; you may want to further constrain this (e.g., via `Uri.TryCreate` or simple pattern checks) to avoid misclassifying arbitrary text as file paths and unexpectedly changing drag effects.

Sourcery 对开源项目是免费的——如果你觉得我们的 Review 有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈来改进后续的 Review。
Original comment in English

Hey - I've left some high level feedback:

  • Calling File.Exists during DragOver can introduce noticeable UI latency, especially for UNC or network paths; consider relaxing this to a syntactic path check (e.g., rooted path / valid extension) and deferring existence checks to the drop handler.
  • The text-path detection currently treats any rooted or \-prefixed string as a path; you may want to further constrain this (e.g., via Uri.TryCreate or simple pattern checks) to avoid misclassifying arbitrary text as file paths and unexpectedly changing drag effects.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Calling `File.Exists` during `DragOver` can introduce noticeable UI latency, especially for UNC or network paths; consider relaxing this to a syntactic path check (e.g., rooted path / valid extension) and deferring existence checks to the drop handler.
- The text-path detection currently treats any rooted or `\`-prefixed string as a path; you may want to further constrain this (e.g., via `Uri.TryCreate` or simple pattern checks) to avoid misclassifying arbitrary text as file paths and unexpectedly changing drag effects.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些高层次的反馈:

  • 现在 DragEnter 逻辑会将普通的根路径(Path.IsPathRooted)视为可复制,但对应的 drop 处理程序仍然只识别 authlib-injector:file:/// 前缀。建议更新 drop 处理逻辑,使其与新的路径识别规则保持一致,以避免悬停和释放操作之间出现行为不一致的问题。
供 AI 智能体使用的提示
Please address the comments from this code review:

## Overall Comments
- The `DragEnter` logic now treats plain rooted paths (`Path.IsPathRooted`) as copyable, but the corresponding drop handler still only recognizes `authlib-injector:` and `file:///` prefixes, so consider updating the drop handling to mirror the new path recognition to avoid inconsistent behavior between hover and drop.

Sourcery 对开源项目是免费的——如果你喜欢我们的代码评审,请考虑帮忙分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English

Hey - I've left some high level feedback:

  • The DragEnter logic now treats plain rooted paths (Path.IsPathRooted) as copyable, but the corresponding drop handler still only recognizes authlib-injector: and file:/// prefixes, so consider updating the drop handling to mirror the new path recognition to avoid inconsistent behavior between hover and drop.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `DragEnter` logic now treats plain rooted paths (`Path.IsPathRooted`) as copyable, but the corresponding drop handler still only recognizes `authlib-injector:` and `file:///` prefixes, so consider updating the drop handling to mirror the new path recognition to avoid inconsistent behavior between hover and drop.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LinQingYuu
Copy link
Copy Markdown
Member Author

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些总体反馈:

  • 引入用于处理根路径文本和文件拖放的 GoTo PathText 标签,说明这些代码路径现在彼此纠缠在一起;建议把共享的文件/路径处理逻辑提取到一个单独的方法中,而不是使用 GoTo,这样控制流会更清晰,也更易于维护。
  • 由于将 PrevData = e.Data 移到了拖放效果检测之前,现在在发生提前返回(例如文本转换失败)时,会更新 PrevData 却不更新 PrevEffects;建议保持这两个字段一起更新(或将 PrevData 移回下面),以避免出现前一状态不一致的组合。
供 AI 代理使用的提示
Please address the comments from this code review:

## Overall Comments
- The introduction of the `GoTo PathText` label for handling rooted path text and file drops suggests the code paths are now intertwined; consider extracting the shared file/path handling into a separate method instead of using `GoTo` so the control flow remains clearer and easier to maintain.
- With `PrevData = e.Data` moved before drop-effect detection, early returns (e.g., when text casting fails) now update `PrevData` without updating `PrevEffects`; consider keeping these two fields updated together (or moving `PrevData` back down) to avoid inconsistent previous-state combinations.

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • The introduction of the GoTo PathText label for handling rooted path text and file drops suggests the code paths are now intertwined; consider extracting the shared file/path handling into a separate method instead of using GoTo so the control flow remains clearer and easier to maintain.
  • With PrevData = e.Data moved before drop-effect detection, early returns (e.g., when text casting fails) now update PrevData without updating PrevEffects; consider keeping these two fields updated together (or moving PrevData back down) to avoid inconsistent previous-state combinations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The introduction of the `GoTo PathText` label for handling rooted path text and file drops suggests the code paths are now intertwined; consider extracting the shared file/path handling into a separate method instead of using `GoTo` so the control flow remains clearer and easier to maintain.
- With `PrevData = e.Data` moved before drop-effect detection, early returns (e.g., when text casting fails) now update `PrevData` without updating `PrevEffects`; consider keeping these two fields updated together (or moving `PrevData` back down) to avoid inconsistent previous-state combinations.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@pcl-ce-automation pcl-ce-automation Bot added size: M PR 大小评估:中型 and removed size: S PR 大小评估:小型 labels Apr 15, 2026
@LinQingYuu LinQingYuu marked this pull request as draft April 15, 2026 12:38
@pcl-ce-automation pcl-ce-automation Bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Apr 15, 2026
@LinQingYuu LinQingYuu removed the request for review from a team April 15, 2026 12:38
@LinQingYuu
Copy link
Copy Markdown
Member Author

算了还是重构掉比较好,这东西太草台班子了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M PR 大小评估:中型 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中

Projects

None yet

Development

Successfully merging this pull request may close these issues.

可使用IDM拖动按钮安装整合包

1 participant