1
This commit is contained in:
1 parent
85fe316cf1
commit
96358eae07
29 files changed
+11307
-200
No files matched your search
@@ -1156,5 +1156,176 @@
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitStageChange": "Stage Changes",
|
||||
"gitUnstageChange": "Unstage Changes",
|
||||
"gitStageAll": "Stage All Changes",
|
||||
"gitUnstageAll": "Unstage All Changes",
|
||||
"gitStageSuccess": "Staged",
|
||||
"gitUnstageSuccess": "Unstaged",
|
||||
"gitCommit": "Commit",
|
||||
"gitCommitMessageHint": "Message",
|
||||
"gitCommitSuccess": "Commit successful",
|
||||
"gitCommitFailed": "Commit failed: {error}",
|
||||
"@gitCommitFailed": {
|
||||
"placeholders": {
|
||||
"error": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDiscardChange": "Discard Changes",
|
||||
"gitDiscardConfirm": "Discard Changes?",
|
||||
"gitDiscardConfirmDesc": "Are you sure you want to discard all unstaged changes in \"{fileName}\"? This cannot be undone.",
|
||||
"@gitDiscardConfirmDesc": {
|
||||
"placeholders": {
|
||||
"fileName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitNoCommitMessage": "Please enter a commit message",
|
||||
"gitNoStagedChangesToCommit": "There are no staged changes. Would you like to stage all changes and commit?",
|
||||
"gitStageAllAndCommit": "Stage All and Commit",
|
||||
"gitGraphTitle": "Graph",
|
||||
"gitNoCommits": "No commit history",
|
||||
"gitCommitDetails": "Commit Details",
|
||||
"gitCommitAuthor": "Author",
|
||||
"gitCommitDate": "Date",
|
||||
"gitCommitHash": "Commit Hash",
|
||||
"gitCopyHash": "Copy Hash",
|
||||
"gitHashCopied": "Commit hash copied to clipboard",
|
||||
"gitCommitParent": "Parent",
|
||||
"gitDiscardAll": "Discard All Changes",
|
||||
"gitDiscardAllChangesTitle": "Discard All Changes?",
|
||||
"gitDiscardAllChangesConfirm": "Are you sure you want to discard all unstaged changes? Modified files will be restored and untracked files will be cleaned. This cannot be undone.",
|
||||
"gitDiscardAllStagedTitle": "Discard All Staged Changes?",
|
||||
"gitDiscardAllStagedConfirm": "Are you sure you want to discard all staged changes? This cannot be undone.",
|
||||
"gitBranches": "Branches",
|
||||
"gitCreateBranch": "Create Branch",
|
||||
"gitBranchNameHint": "Enter branch name",
|
||||
"gitSwitchBranchSuccess": "Switched to branch {branch}",
|
||||
"@gitSwitchBranchSuccess": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitCreateBranchSuccess": "Created and switched to branch {branch}",
|
||||
"@gitCreateBranchSuccess": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDeleteBranch": "Delete Branch",
|
||||
"gitDeleteBranchConfirm": "Are you sure you want to delete branch {branch}?",
|
||||
"@gitDeleteBranchConfirm": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDeleteBranchSuccess": "Deleted branch {branch}",
|
||||
"@gitDeleteBranchSuccess": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitCannotDeleteCurrentBranch": "Cannot delete the current branch",
|
||||
"gitUndoLastCommit": "Undo Last Commit",
|
||||
"gitUndoLastCommitConfirm": "Are you sure you want to undo the last commit? Changes will be kept in the staging area.",
|
||||
"gitUndoLastCommitSuccess": "Undid last commit",
|
||||
"gitStash": "Stash",
|
||||
"gitStashChanges": "Stash Changes",
|
||||
"gitStashChangesSuccess": "Stashed current changes",
|
||||
"gitStashPop": "Pop Latest Stash",
|
||||
"gitStashPopSuccess": "Restored latest stash",
|
||||
"gitNoStashFound": "No stashes found",
|
||||
"gitAddToGitignore": "Add to .gitignore",
|
||||
"gitAddedToGitignore": "Added to .gitignore",
|
||||
"gitMoreActions": "More Actions",
|
||||
"gitOpenFile": "Open File",
|
||||
"gitTags": "Tags",
|
||||
"gitCreateTag": "Create Tag",
|
||||
"gitTagNameHint": "Enter tag name (e.g. v1.0.0)",
|
||||
"gitTagMessageHint": "Tag message (optional)",
|
||||
"gitDeleteTag": "Delete Tag",
|
||||
"gitDeleteTagConfirm": "Are you sure you want to delete tag {tag}?",
|
||||
"@gitDeleteTagConfirm": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitCreateTagSuccess": "Created tag {tag}",
|
||||
"@gitCreateTagSuccess": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDeleteTagSuccess": "Deleted tag {tag}",
|
||||
"@gitDeleteTagSuccess": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitSwitchTagSuccess": "Checked out to tag {tag}",
|
||||
"@gitSwitchTagSuccess": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitNoTags": "No tags",
|
||||
"gitSelectBranchToDelete": "Select branch to delete",
|
||||
"gitSelectTagToDelete": "Select tag to delete",
|
||||
"gitSearchBranches": "Search branches...",
|
||||
"gitSearchTags": "Search tags...",
|
||||
"gitNoBranches": "No branches",
|
||||
"gitDiff": "Diff",
|
||||
"gitDiffOriginal": "Original",
|
||||
"gitDiffModified": "Modified",
|
||||
"gitDiffSplitView": "Split View",
|
||||
"gitDiffUnifiedView": "Unified View",
|
||||
"gitDiffPrevChange": "Previous Change",
|
||||
"gitDiffNextChange": "Next Change",
|
||||
"gitDiffBinaryOrEmpty": "Binary or unsupported file for comparison",
|
||||
"gitDiffNoChanges": "This file is identical to the base version, no differences found",
|
||||
"gitDiffStageTooltip": "Stage this file",
|
||||
"gitDiffUnstageTooltip": "Unstage this file",
|
||||
"gitDiffDiscardTooltip": "Discard changes in this file",
|
||||
"gitExpandAll": "Expand All",
|
||||
"gitLoadMoreCommits": "Load more commits ({count})",
|
||||
"@gitLoadMoreCommits": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"gitLoadedCommitsCount": "Showing {loaded} of {total} commits",
|
||||
"@gitLoadedCommitsCount": {
|
||||
"placeholders": {
|
||||
"loaded": { "type": "int" },
|
||||
"total": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"gitAllCommitsLoaded": "All {count} commits loaded",
|
||||
"@gitAllCommitsLoaded": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"gitLoadingMoreCommits": "Loading more commits...",
|
||||
"searchExpandAllMatchesInFile": "Expand all matches"
|
||||
}
|
||||
@@ -3201,6 +3201,678 @@ abstract class AppLocalizations {
|
||||
int matchCount,
|
||||
String replaceText,
|
||||
);
|
||||
|
||||
/// No description provided for @gitNotInstalled.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'未检测到 Git'**
|
||||
String get gitNotInstalled;
|
||||
|
||||
/// No description provided for @gitNotInstalledDesc.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'系统中未检测到 Git 命令行工具。请在系统终端或 Linux 容器中安装 git(如执行 apt update && apt install -y git)。'**
|
||||
String get gitNotInstalledDesc;
|
||||
|
||||
/// No description provided for @gitNeedInstall.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'需要安装 Git'**
|
||||
String get gitNeedInstall;
|
||||
|
||||
/// No description provided for @gitInstallAction.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'安装 Git'**
|
||||
String get gitInstallAction;
|
||||
|
||||
/// No description provided for @gitInstallingProgress.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'正在安装 Git...'**
|
||||
String get gitInstallingProgress;
|
||||
|
||||
/// No description provided for @gitInstallSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'Git 安装成功'**
|
||||
String get gitInstallSuccess;
|
||||
|
||||
/// No description provided for @gitInstallFailed.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'Git 安装失败: {error}'**
|
||||
String gitInstallFailed(String error);
|
||||
|
||||
/// No description provided for @gitNoRepoFound.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'当前工程尚未初始化为 Git 仓库'**
|
||||
String get gitNoRepoFound;
|
||||
|
||||
/// No description provided for @gitNoRepoDesc.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'初始化本地 Git 仓库后,即可使用版本控制、分支管理及变更追踪功能。'**
|
||||
String get gitNoRepoDesc;
|
||||
|
||||
/// No description provided for @gitInitRepo.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'初始化 Git 仓库'**
|
||||
String get gitInitRepo;
|
||||
|
||||
/// No description provided for @gitInitializing.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'正在初始化 Git 仓库...'**
|
||||
String get gitInitializing;
|
||||
|
||||
/// No description provided for @gitInitSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'Git 仓库初始化成功'**
|
||||
String get gitInitSuccess;
|
||||
|
||||
/// No description provided for @gitInitFailed.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'Git 仓库初始化失败: {error}'**
|
||||
String gitInitFailed(String error);
|
||||
|
||||
/// No description provided for @gitRepository.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'仓库'**
|
||||
String get gitRepository;
|
||||
|
||||
/// No description provided for @gitCurrentBranch.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'当前分支: {branch}'**
|
||||
String gitCurrentBranch(String branch);
|
||||
|
||||
/// No description provided for @gitSwitchRepo.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'切换仓库'**
|
||||
String get gitSwitchRepo;
|
||||
|
||||
/// No description provided for @gitRefresh.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'刷新 Git 状态'**
|
||||
String get gitRefresh;
|
||||
|
||||
/// No description provided for @gitChanges.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'更改'**
|
||||
String get gitChanges;
|
||||
|
||||
/// No description provided for @gitStagedChanges.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂存的更改'**
|
||||
String get gitStagedChanges;
|
||||
|
||||
/// No description provided for @gitNoChanges.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂无任何文件更改'**
|
||||
String get gitNoChanges;
|
||||
|
||||
/// No description provided for @gitStatusUntracked.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'未跟踪'**
|
||||
String get gitStatusUntracked;
|
||||
|
||||
/// No description provided for @gitStatusModified.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已修改'**
|
||||
String get gitStatusModified;
|
||||
|
||||
/// No description provided for @gitStatusAdded.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'新增'**
|
||||
String get gitStatusAdded;
|
||||
|
||||
/// No description provided for @gitStatusDeleted.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已删除'**
|
||||
String get gitStatusDeleted;
|
||||
|
||||
/// No description provided for @gitStatusRenamed.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'重命名'**
|
||||
String get gitStatusRenamed;
|
||||
|
||||
/// No description provided for @gitStatusConflict.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'冲突'**
|
||||
String get gitStatusConflict;
|
||||
|
||||
/// No description provided for @gitMultipleReposDetected.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'检测到多个 Git 仓库 ({count})'**
|
||||
String gitMultipleReposDetected(int count);
|
||||
|
||||
/// No description provided for @gitStageChange.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂存更改'**
|
||||
String get gitStageChange;
|
||||
|
||||
/// No description provided for @gitUnstageChange.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'取消暂存更改'**
|
||||
String get gitUnstageChange;
|
||||
|
||||
/// No description provided for @gitStageAll.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'全部暂存更改'**
|
||||
String get gitStageAll;
|
||||
|
||||
/// No description provided for @gitUnstageAll.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'全部取消暂存更改'**
|
||||
String get gitUnstageAll;
|
||||
|
||||
/// No description provided for @gitStageSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已暂存'**
|
||||
String get gitStageSuccess;
|
||||
|
||||
/// No description provided for @gitUnstageSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已取消暂存'**
|
||||
String get gitUnstageSuccess;
|
||||
|
||||
/// No description provided for @gitCommit.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交'**
|
||||
String get gitCommit;
|
||||
|
||||
/// No description provided for @gitCommitMessageHint.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交信息'**
|
||||
String get gitCommitMessageHint;
|
||||
|
||||
/// No description provided for @gitCommitSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交成功'**
|
||||
String get gitCommitSuccess;
|
||||
|
||||
/// No description provided for @gitCommitFailed.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交失败: {error}'**
|
||||
String gitCommitFailed(String error);
|
||||
|
||||
/// No description provided for @gitDiscardChange.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'放弃更改'**
|
||||
String get gitDiscardChange;
|
||||
|
||||
/// No description provided for @gitDiscardConfirm.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'放弃更改?'**
|
||||
String get gitDiscardConfirm;
|
||||
|
||||
/// No description provided for @gitDiscardConfirmDesc.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确定要放弃对 \"{fileName}\" 的所有未暂存更改吗?此操作无法撤销。'**
|
||||
String gitDiscardConfirmDesc(String fileName);
|
||||
|
||||
/// No description provided for @gitNoCommitMessage.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'请输入提交信息'**
|
||||
String get gitNoCommitMessage;
|
||||
|
||||
/// No description provided for @gitNoStagedChangesToCommit.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂存区没有已暂存的更改,是否全部暂存并直接提交?'**
|
||||
String get gitNoStagedChangesToCommit;
|
||||
|
||||
/// No description provided for @gitStageAllAndCommit.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'全部暂存并提交'**
|
||||
String get gitStageAllAndCommit;
|
||||
|
||||
/// No description provided for @gitGraphTitle.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'图表'**
|
||||
String get gitGraphTitle;
|
||||
|
||||
/// No description provided for @gitNoCommits.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂无提交历史'**
|
||||
String get gitNoCommits;
|
||||
|
||||
/// No description provided for @gitCommitDetails.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交详情'**
|
||||
String get gitCommitDetails;
|
||||
|
||||
/// No description provided for @gitCommitAuthor.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'作者'**
|
||||
String get gitCommitAuthor;
|
||||
|
||||
/// No description provided for @gitCommitDate.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交日期'**
|
||||
String get gitCommitDate;
|
||||
|
||||
/// No description provided for @gitCommitHash.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'提交哈希'**
|
||||
String get gitCommitHash;
|
||||
|
||||
/// No description provided for @gitCopyHash.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'复制哈希'**
|
||||
String get gitCopyHash;
|
||||
|
||||
/// No description provided for @gitHashCopied.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已复制提交哈希到剪贴板'**
|
||||
String get gitHashCopied;
|
||||
|
||||
/// No description provided for @gitCommitParent.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'父提交'**
|
||||
String get gitCommitParent;
|
||||
|
||||
/// No description provided for @gitDiscardAll.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'全部放弃更改'**
|
||||
String get gitDiscardAll;
|
||||
|
||||
/// No description provided for @gitDiscardAllChangesTitle.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'放弃所有未暂存更改?'**
|
||||
String get gitDiscardAllChangesTitle;
|
||||
|
||||
/// No description provided for @gitDiscardAllChangesConfirm.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确定要放弃所有未暂存更改吗?所有已修改的文件将恢复,未跟踪的新文件将被清除,此操作无法撤销。'**
|
||||
String get gitDiscardAllChangesConfirm;
|
||||
|
||||
/// No description provided for @gitDiscardAllStagedTitle.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'放弃所有已暂存更改?'**
|
||||
String get gitDiscardAllStagedTitle;
|
||||
|
||||
/// No description provided for @gitDiscardAllStagedConfirm.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确定要放弃所有已暂存的更改吗?所选文件的修改将被彻底恢复,此操作无法撤销。'**
|
||||
String get gitDiscardAllStagedConfirm;
|
||||
|
||||
/// No description provided for @gitBranches.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'分支'**
|
||||
String get gitBranches;
|
||||
|
||||
/// No description provided for @gitCreateBranch.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'创建新分支'**
|
||||
String get gitCreateBranch;
|
||||
|
||||
/// No description provided for @gitBranchNameHint.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'输入新分支名称'**
|
||||
String get gitBranchNameHint;
|
||||
|
||||
/// No description provided for @gitSwitchBranchSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已切换至分支 {branch}'**
|
||||
String gitSwitchBranchSuccess(String branch);
|
||||
|
||||
/// No description provided for @gitCreateBranchSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已创建并切换至新分支 {branch}'**
|
||||
String gitCreateBranchSuccess(String branch);
|
||||
|
||||
/// No description provided for @gitDeleteBranch.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'删除分支'**
|
||||
String get gitDeleteBranch;
|
||||
|
||||
/// No description provided for @gitDeleteBranchConfirm.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确定要删除本地分支 {branch} 吗?'**
|
||||
String gitDeleteBranchConfirm(String branch);
|
||||
|
||||
/// No description provided for @gitDeleteBranchSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已删除分支 {branch}'**
|
||||
String gitDeleteBranchSuccess(String branch);
|
||||
|
||||
/// No description provided for @gitCannotDeleteCurrentBranch.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'无法删除当前所在分支'**
|
||||
String get gitCannotDeleteCurrentBranch;
|
||||
|
||||
/// No description provided for @gitUndoLastCommit.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'撤销上次提交'**
|
||||
String get gitUndoLastCommit;
|
||||
|
||||
/// No description provided for @gitUndoLastCommitConfirm.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确定要撤销上一次提交吗?代码更改将保留在暂存区。'**
|
||||
String get gitUndoLastCommitConfirm;
|
||||
|
||||
/// No description provided for @gitUndoLastCommitSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已撤销上一次提交'**
|
||||
String get gitUndoLastCommitSuccess;
|
||||
|
||||
/// No description provided for @gitStash.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'贮藏'**
|
||||
String get gitStash;
|
||||
|
||||
/// No description provided for @gitStashChanges.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'贮藏当前更改'**
|
||||
String get gitStashChanges;
|
||||
|
||||
/// No description provided for @gitStashChangesSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已将当前更改暂存至贮藏栈'**
|
||||
String get gitStashChangesSuccess;
|
||||
|
||||
/// No description provided for @gitStashPop.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'恢复最近贮藏 (Pop)'**
|
||||
String get gitStashPop;
|
||||
|
||||
/// No description provided for @gitStashPopSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已恢复最近的贮藏更改'**
|
||||
String get gitStashPopSuccess;
|
||||
|
||||
/// No description provided for @gitNoStashFound.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'当前没有可恢复的贮藏记录'**
|
||||
String get gitNoStashFound;
|
||||
|
||||
/// No description provided for @gitAddToGitignore.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'添加到 .gitignore'**
|
||||
String get gitAddToGitignore;
|
||||
|
||||
/// No description provided for @gitAddedToGitignore.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已添加至 .gitignore'**
|
||||
String get gitAddedToGitignore;
|
||||
|
||||
/// No description provided for @gitMoreActions.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'更多操作'**
|
||||
String get gitMoreActions;
|
||||
|
||||
/// No description provided for @gitOpenFile.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'打开文件'**
|
||||
String get gitOpenFile;
|
||||
|
||||
/// No description provided for @gitTags.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'标签'**
|
||||
String get gitTags;
|
||||
|
||||
/// No description provided for @gitCreateTag.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'创建新标签'**
|
||||
String get gitCreateTag;
|
||||
|
||||
/// No description provided for @gitTagNameHint.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'输入标签名称 (例如 v1.0.0)'**
|
||||
String get gitTagNameHint;
|
||||
|
||||
/// No description provided for @gitTagMessageHint.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'标签附注信息 (可选)'**
|
||||
String get gitTagMessageHint;
|
||||
|
||||
/// No description provided for @gitDeleteTag.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'删除标签'**
|
||||
String get gitDeleteTag;
|
||||
|
||||
/// No description provided for @gitDeleteTagConfirm.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确定要删除本地标签 {tag} 吗?'**
|
||||
String gitDeleteTagConfirm(String tag);
|
||||
|
||||
/// No description provided for @gitCreateTagSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已创建标签 {tag}'**
|
||||
String gitCreateTagSuccess(String tag);
|
||||
|
||||
/// No description provided for @gitDeleteTagSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已删除标签 {tag}'**
|
||||
String gitDeleteTagSuccess(String tag);
|
||||
|
||||
/// No description provided for @gitSwitchTagSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已检出至标签 {tag}'**
|
||||
String gitSwitchTagSuccess(String tag);
|
||||
|
||||
/// No description provided for @gitNoTags.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂无标签'**
|
||||
String get gitNoTags;
|
||||
|
||||
/// No description provided for @gitSelectBranchToDelete.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'选择要删除的分支'**
|
||||
String get gitSelectBranchToDelete;
|
||||
|
||||
/// No description provided for @gitSelectTagToDelete.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'选择要删除的标签'**
|
||||
String get gitSelectTagToDelete;
|
||||
|
||||
/// No description provided for @gitSearchBranches.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'搜索分支...'**
|
||||
String get gitSearchBranches;
|
||||
|
||||
/// No description provided for @gitSearchTags.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'搜索标签...'**
|
||||
String get gitSearchTags;
|
||||
|
||||
/// No description provided for @gitNoBranches.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂无分支'**
|
||||
String get gitNoBranches;
|
||||
|
||||
/// No description provided for @gitDiff.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'差异对比'**
|
||||
String get gitDiff;
|
||||
|
||||
/// No description provided for @gitDiffOriginal.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'原始版本'**
|
||||
String get gitDiffOriginal;
|
||||
|
||||
/// No description provided for @gitDiffModified.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'修改版本'**
|
||||
String get gitDiffModified;
|
||||
|
||||
/// No description provided for @gitDiffSplitView.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'双屏分栏'**
|
||||
String get gitDiffSplitView;
|
||||
|
||||
/// No description provided for @gitDiffUnifiedView.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'单屏内联'**
|
||||
String get gitDiffUnifiedView;
|
||||
|
||||
/// No description provided for @gitDiffPrevChange.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'上一处更改'**
|
||||
String get gitDiffPrevChange;
|
||||
|
||||
/// No description provided for @gitDiffNextChange.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'下一处更改'**
|
||||
String get gitDiffNextChange;
|
||||
|
||||
/// No description provided for @gitDiffBinaryOrEmpty.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'二进制或不支持比较的文件'**
|
||||
String get gitDiffBinaryOrEmpty;
|
||||
|
||||
/// No description provided for @gitDiffNoChanges.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'该文件与基准版本完全一致,暂无差异'**
|
||||
String get gitDiffNoChanges;
|
||||
|
||||
/// No description provided for @gitDiffStageTooltip.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'暂存此文件更改'**
|
||||
String get gitDiffStageTooltip;
|
||||
|
||||
/// No description provided for @gitDiffUnstageTooltip.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'取消暂存此文件'**
|
||||
String get gitDiffUnstageTooltip;
|
||||
|
||||
/// No description provided for @gitDiffDiscardTooltip.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'放弃此文件更改'**
|
||||
String get gitDiffDiscardTooltip;
|
||||
|
||||
/// No description provided for @gitExpandAll.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'全部展开'**
|
||||
String get gitExpandAll;
|
||||
|
||||
/// No description provided for @gitLoadMoreCommits.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'加载更多提交 ({count})'**
|
||||
String gitLoadMoreCommits(int count);
|
||||
|
||||
/// No description provided for @gitLoadedCommitsCount.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已显示 {loaded} / {total} 个提交'**
|
||||
String gitLoadedCommitsCount(int loaded, int total);
|
||||
|
||||
/// No description provided for @gitAllCommitsLoaded.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'已显示全部 {count} 个提交'**
|
||||
String gitAllCommitsLoaded(int count);
|
||||
|
||||
/// No description provided for @gitLoadingMoreCommits.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'正在加载更多提交...'**
|
||||
String get gitLoadingMoreCommits;
|
||||
|
||||
/// No description provided for @searchExpandAllMatchesInFile.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'展开全部匹配项'**
|
||||
String get searchExpandAllMatchesInFile;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate
|
||||
|
||||
@@ -1933,4 +1933,382 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
) {
|
||||
return 'Are you sure you want to replace all $matchCount occurrences in \"$fileName\" with \"$replaceText\"?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNotInstalled => 'Git Not Found';
|
||||
|
||||
@override
|
||||
String get gitNotInstalledDesc =>
|
||||
'Git command-line tool was not found on your system. Please install git in your terminal or Linux container (e.g. apt update && apt install -y git).';
|
||||
|
||||
@override
|
||||
String get gitNeedInstall => 'Git Installation Required';
|
||||
|
||||
@override
|
||||
String get gitInstallAction => 'Install Git';
|
||||
|
||||
@override
|
||||
String get gitInstallingProgress => 'Installing Git...';
|
||||
|
||||
@override
|
||||
String get gitInstallSuccess => 'Git installed successfully';
|
||||
|
||||
@override
|
||||
String gitInstallFailed(String error) {
|
||||
return 'Failed to install Git: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNoRepoFound => 'No Git Repository';
|
||||
|
||||
@override
|
||||
String get gitNoRepoDesc =>
|
||||
'Initialize a Git repository to start version control, branch management, and tracking code changes.';
|
||||
|
||||
@override
|
||||
String get gitInitRepo => 'Initialize Repository';
|
||||
|
||||
@override
|
||||
String get gitInitializing => 'Initializing Git repository...';
|
||||
|
||||
@override
|
||||
String get gitInitSuccess => 'Git repository initialized successfully';
|
||||
|
||||
@override
|
||||
String gitInitFailed(String error) {
|
||||
return 'Failed to initialize Git repository: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitRepository => 'Repository';
|
||||
|
||||
@override
|
||||
String gitCurrentBranch(String branch) {
|
||||
return 'Branch: $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitSwitchRepo => 'Switch Repository';
|
||||
|
||||
@override
|
||||
String get gitRefresh => 'Refresh Git';
|
||||
|
||||
@override
|
||||
String get gitChanges => 'Changes';
|
||||
|
||||
@override
|
||||
String get gitStagedChanges => 'Staged Changes';
|
||||
|
||||
@override
|
||||
String get gitNoChanges => 'No changes detected';
|
||||
|
||||
@override
|
||||
String get gitStatusUntracked => 'Untracked';
|
||||
|
||||
@override
|
||||
String get gitStatusModified => 'Modified';
|
||||
|
||||
@override
|
||||
String get gitStatusAdded => 'Added';
|
||||
|
||||
@override
|
||||
String get gitStatusDeleted => 'Deleted';
|
||||
|
||||
@override
|
||||
String get gitStatusRenamed => 'Renamed';
|
||||
|
||||
@override
|
||||
String get gitStatusConflict => 'Conflict';
|
||||
|
||||
@override
|
||||
String gitMultipleReposDetected(int count) {
|
||||
return 'Multiple Repositories ($count)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitStageChange => 'Stage Changes';
|
||||
|
||||
@override
|
||||
String get gitUnstageChange => 'Unstage Changes';
|
||||
|
||||
@override
|
||||
String get gitStageAll => 'Stage All Changes';
|
||||
|
||||
@override
|
||||
String get gitUnstageAll => 'Unstage All Changes';
|
||||
|
||||
@override
|
||||
String get gitStageSuccess => 'Staged';
|
||||
|
||||
@override
|
||||
String get gitUnstageSuccess => 'Unstaged';
|
||||
|
||||
@override
|
||||
String get gitCommit => 'Commit';
|
||||
|
||||
@override
|
||||
String get gitCommitMessageHint => 'Message';
|
||||
|
||||
@override
|
||||
String get gitCommitSuccess => 'Commit successful';
|
||||
|
||||
@override
|
||||
String gitCommitFailed(String error) {
|
||||
return 'Commit failed: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitDiscardChange => 'Discard Changes';
|
||||
|
||||
@override
|
||||
String get gitDiscardConfirm => 'Discard Changes?';
|
||||
|
||||
@override
|
||||
String gitDiscardConfirmDesc(String fileName) {
|
||||
return 'Are you sure you want to discard all unstaged changes in \"$fileName\"? This cannot be undone.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNoCommitMessage => 'Please enter a commit message';
|
||||
|
||||
@override
|
||||
String get gitNoStagedChangesToCommit =>
|
||||
'There are no staged changes. Would you like to stage all changes and commit?';
|
||||
|
||||
@override
|
||||
String get gitStageAllAndCommit => 'Stage All and Commit';
|
||||
|
||||
@override
|
||||
String get gitGraphTitle => 'Graph';
|
||||
|
||||
@override
|
||||
String get gitNoCommits => 'No commit history';
|
||||
|
||||
@override
|
||||
String get gitCommitDetails => 'Commit Details';
|
||||
|
||||
@override
|
||||
String get gitCommitAuthor => 'Author';
|
||||
|
||||
@override
|
||||
String get gitCommitDate => 'Date';
|
||||
|
||||
@override
|
||||
String get gitCommitHash => 'Commit Hash';
|
||||
|
||||
@override
|
||||
String get gitCopyHash => 'Copy Hash';
|
||||
|
||||
@override
|
||||
String get gitHashCopied => 'Commit hash copied to clipboard';
|
||||
|
||||
@override
|
||||
String get gitCommitParent => 'Parent';
|
||||
|
||||
@override
|
||||
String get gitDiscardAll => 'Discard All Changes';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllChangesTitle => 'Discard All Changes?';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllChangesConfirm =>
|
||||
'Are you sure you want to discard all unstaged changes? Modified files will be restored and untracked files will be cleaned. This cannot be undone.';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllStagedTitle => 'Discard All Staged Changes?';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllStagedConfirm =>
|
||||
'Are you sure you want to discard all staged changes? This cannot be undone.';
|
||||
|
||||
@override
|
||||
String get gitBranches => 'Branches';
|
||||
|
||||
@override
|
||||
String get gitCreateBranch => 'Create Branch';
|
||||
|
||||
@override
|
||||
String get gitBranchNameHint => 'Enter branch name';
|
||||
|
||||
@override
|
||||
String gitSwitchBranchSuccess(String branch) {
|
||||
return 'Switched to branch $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitCreateBranchSuccess(String branch) {
|
||||
return 'Created and switched to branch $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitDeleteBranch => 'Delete Branch';
|
||||
|
||||
@override
|
||||
String gitDeleteBranchConfirm(String branch) {
|
||||
return 'Are you sure you want to delete branch $branch?';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitDeleteBranchSuccess(String branch) {
|
||||
return 'Deleted branch $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitCannotDeleteCurrentBranch => 'Cannot delete the current branch';
|
||||
|
||||
@override
|
||||
String get gitUndoLastCommit => 'Undo Last Commit';
|
||||
|
||||
@override
|
||||
String get gitUndoLastCommitConfirm =>
|
||||
'Are you sure you want to undo the last commit? Changes will be kept in the staging area.';
|
||||
|
||||
@override
|
||||
String get gitUndoLastCommitSuccess => 'Undid last commit';
|
||||
|
||||
@override
|
||||
String get gitStash => 'Stash';
|
||||
|
||||
@override
|
||||
String get gitStashChanges => 'Stash Changes';
|
||||
|
||||
@override
|
||||
String get gitStashChangesSuccess => 'Stashed current changes';
|
||||
|
||||
@override
|
||||
String get gitStashPop => 'Pop Latest Stash';
|
||||
|
||||
@override
|
||||
String get gitStashPopSuccess => 'Restored latest stash';
|
||||
|
||||
@override
|
||||
String get gitNoStashFound => 'No stashes found';
|
||||
|
||||
@override
|
||||
String get gitAddToGitignore => 'Add to .gitignore';
|
||||
|
||||
@override
|
||||
String get gitAddedToGitignore => 'Added to .gitignore';
|
||||
|
||||
@override
|
||||
String get gitMoreActions => 'More Actions';
|
||||
|
||||
@override
|
||||
String get gitOpenFile => 'Open File';
|
||||
|
||||
@override
|
||||
String get gitTags => 'Tags';
|
||||
|
||||
@override
|
||||
String get gitCreateTag => 'Create Tag';
|
||||
|
||||
@override
|
||||
String get gitTagNameHint => 'Enter tag name (e.g. v1.0.0)';
|
||||
|
||||
@override
|
||||
String get gitTagMessageHint => 'Tag message (optional)';
|
||||
|
||||
@override
|
||||
String get gitDeleteTag => 'Delete Tag';
|
||||
|
||||
@override
|
||||
String gitDeleteTagConfirm(String tag) {
|
||||
return 'Are you sure you want to delete tag $tag?';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitCreateTagSuccess(String tag) {
|
||||
return 'Created tag $tag';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitDeleteTagSuccess(String tag) {
|
||||
return 'Deleted tag $tag';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitSwitchTagSuccess(String tag) {
|
||||
return 'Checked out to tag $tag';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNoTags => 'No tags';
|
||||
|
||||
@override
|
||||
String get gitSelectBranchToDelete => 'Select branch to delete';
|
||||
|
||||
@override
|
||||
String get gitSelectTagToDelete => 'Select tag to delete';
|
||||
|
||||
@override
|
||||
String get gitSearchBranches => 'Search branches...';
|
||||
|
||||
@override
|
||||
String get gitSearchTags => 'Search tags...';
|
||||
|
||||
@override
|
||||
String get gitNoBranches => 'No branches';
|
||||
|
||||
@override
|
||||
String get gitDiff => 'Diff';
|
||||
|
||||
@override
|
||||
String get gitDiffOriginal => 'Original';
|
||||
|
||||
@override
|
||||
String get gitDiffModified => 'Modified';
|
||||
|
||||
@override
|
||||
String get gitDiffSplitView => 'Split View';
|
||||
|
||||
@override
|
||||
String get gitDiffUnifiedView => 'Unified View';
|
||||
|
||||
@override
|
||||
String get gitDiffPrevChange => 'Previous Change';
|
||||
|
||||
@override
|
||||
String get gitDiffNextChange => 'Next Change';
|
||||
|
||||
@override
|
||||
String get gitDiffBinaryOrEmpty =>
|
||||
'Binary or unsupported file for comparison';
|
||||
|
||||
@override
|
||||
String get gitDiffNoChanges =>
|
||||
'This file is identical to the base version, no differences found';
|
||||
|
||||
@override
|
||||
String get gitDiffStageTooltip => 'Stage this file';
|
||||
|
||||
@override
|
||||
String get gitDiffUnstageTooltip => 'Unstage this file';
|
||||
|
||||
@override
|
||||
String get gitDiffDiscardTooltip => 'Discard changes in this file';
|
||||
|
||||
@override
|
||||
String get gitExpandAll => 'Expand All';
|
||||
|
||||
@override
|
||||
String gitLoadMoreCommits(int count) {
|
||||
return 'Load more commits ($count)';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitLoadedCommitsCount(int loaded, int total) {
|
||||
return 'Showing $loaded of $total commits';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitAllCommitsLoaded(int count) {
|
||||
return 'All $count commits loaded';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitLoadingMoreCommits => 'Loading more commits...';
|
||||
|
||||
@override
|
||||
String get searchExpandAllMatchesInFile => 'Expand all matches';
|
||||
}
|
||||
@@ -1873,4 +1873,377 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
) {
|
||||
return '确定要在 \"$fileName\" 中将全部 $matchCount 处匹配替换为 \"$replaceText\" 吗?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNotInstalled => '未检测到 Git';
|
||||
|
||||
@override
|
||||
String get gitNotInstalledDesc =>
|
||||
'系统中未检测到 Git 命令行工具。请在系统终端或 Linux 容器中安装 git(如执行 apt update && apt install -y git)。';
|
||||
|
||||
@override
|
||||
String get gitNeedInstall => '需要安装 Git';
|
||||
|
||||
@override
|
||||
String get gitInstallAction => '安装 Git';
|
||||
|
||||
@override
|
||||
String get gitInstallingProgress => '正在安装 Git...';
|
||||
|
||||
@override
|
||||
String get gitInstallSuccess => 'Git 安装成功';
|
||||
|
||||
@override
|
||||
String gitInstallFailed(String error) {
|
||||
return 'Git 安装失败: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNoRepoFound => '当前工程尚未初始化为 Git 仓库';
|
||||
|
||||
@override
|
||||
String get gitNoRepoDesc => '初始化本地 Git 仓库后,即可使用版本控制、分支管理及变更追踪功能。';
|
||||
|
||||
@override
|
||||
String get gitInitRepo => '初始化 Git 仓库';
|
||||
|
||||
@override
|
||||
String get gitInitializing => '正在初始化 Git 仓库...';
|
||||
|
||||
@override
|
||||
String get gitInitSuccess => 'Git 仓库初始化成功';
|
||||
|
||||
@override
|
||||
String gitInitFailed(String error) {
|
||||
return 'Git 仓库初始化失败: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitRepository => '仓库';
|
||||
|
||||
@override
|
||||
String gitCurrentBranch(String branch) {
|
||||
return '当前分支: $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitSwitchRepo => '切换仓库';
|
||||
|
||||
@override
|
||||
String get gitRefresh => '刷新 Git 状态';
|
||||
|
||||
@override
|
||||
String get gitChanges => '更改';
|
||||
|
||||
@override
|
||||
String get gitStagedChanges => '暂存的更改';
|
||||
|
||||
@override
|
||||
String get gitNoChanges => '暂无任何文件更改';
|
||||
|
||||
@override
|
||||
String get gitStatusUntracked => '未跟踪';
|
||||
|
||||
@override
|
||||
String get gitStatusModified => '已修改';
|
||||
|
||||
@override
|
||||
String get gitStatusAdded => '新增';
|
||||
|
||||
@override
|
||||
String get gitStatusDeleted => '已删除';
|
||||
|
||||
@override
|
||||
String get gitStatusRenamed => '重命名';
|
||||
|
||||
@override
|
||||
String get gitStatusConflict => '冲突';
|
||||
|
||||
@override
|
||||
String gitMultipleReposDetected(int count) {
|
||||
return '检测到多个 Git 仓库 ($count)';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitStageChange => '暂存更改';
|
||||
|
||||
@override
|
||||
String get gitUnstageChange => '取消暂存更改';
|
||||
|
||||
@override
|
||||
String get gitStageAll => '全部暂存更改';
|
||||
|
||||
@override
|
||||
String get gitUnstageAll => '全部取消暂存更改';
|
||||
|
||||
@override
|
||||
String get gitStageSuccess => '已暂存';
|
||||
|
||||
@override
|
||||
String get gitUnstageSuccess => '已取消暂存';
|
||||
|
||||
@override
|
||||
String get gitCommit => '提交';
|
||||
|
||||
@override
|
||||
String get gitCommitMessageHint => '提交信息';
|
||||
|
||||
@override
|
||||
String get gitCommitSuccess => '提交成功';
|
||||
|
||||
@override
|
||||
String gitCommitFailed(String error) {
|
||||
return '提交失败: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitDiscardChange => '放弃更改';
|
||||
|
||||
@override
|
||||
String get gitDiscardConfirm => '放弃更改?';
|
||||
|
||||
@override
|
||||
String gitDiscardConfirmDesc(String fileName) {
|
||||
return '确定要放弃对 \"$fileName\" 的所有未暂存更改吗?此操作无法撤销。';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNoCommitMessage => '请输入提交信息';
|
||||
|
||||
@override
|
||||
String get gitNoStagedChangesToCommit => '暂存区没有已暂存的更改,是否全部暂存并直接提交?';
|
||||
|
||||
@override
|
||||
String get gitStageAllAndCommit => '全部暂存并提交';
|
||||
|
||||
@override
|
||||
String get gitGraphTitle => '图表';
|
||||
|
||||
@override
|
||||
String get gitNoCommits => '暂无提交历史';
|
||||
|
||||
@override
|
||||
String get gitCommitDetails => '提交详情';
|
||||
|
||||
@override
|
||||
String get gitCommitAuthor => '作者';
|
||||
|
||||
@override
|
||||
String get gitCommitDate => '提交日期';
|
||||
|
||||
@override
|
||||
String get gitCommitHash => '提交哈希';
|
||||
|
||||
@override
|
||||
String get gitCopyHash => '复制哈希';
|
||||
|
||||
@override
|
||||
String get gitHashCopied => '已复制提交哈希到剪贴板';
|
||||
|
||||
@override
|
||||
String get gitCommitParent => '父提交';
|
||||
|
||||
@override
|
||||
String get gitDiscardAll => '全部放弃更改';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllChangesTitle => '放弃所有未暂存更改?';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllChangesConfirm =>
|
||||
'确定要放弃所有未暂存更改吗?所有已修改的文件将恢复,未跟踪的新文件将被清除,此操作无法撤销。';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllStagedTitle => '放弃所有已暂存更改?';
|
||||
|
||||
@override
|
||||
String get gitDiscardAllStagedConfirm =>
|
||||
'确定要放弃所有已暂存的更改吗?所选文件的修改将被彻底恢复,此操作无法撤销。';
|
||||
|
||||
@override
|
||||
String get gitBranches => '分支';
|
||||
|
||||
@override
|
||||
String get gitCreateBranch => '创建新分支';
|
||||
|
||||
@override
|
||||
String get gitBranchNameHint => '输入新分支名称';
|
||||
|
||||
@override
|
||||
String gitSwitchBranchSuccess(String branch) {
|
||||
return '已切换至分支 $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitCreateBranchSuccess(String branch) {
|
||||
return '已创建并切换至新分支 $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitDeleteBranch => '删除分支';
|
||||
|
||||
@override
|
||||
String gitDeleteBranchConfirm(String branch) {
|
||||
return '确定要删除本地分支 $branch 吗?';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitDeleteBranchSuccess(String branch) {
|
||||
return '已删除分支 $branch';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitCannotDeleteCurrentBranch => '无法删除当前所在分支';
|
||||
|
||||
@override
|
||||
String get gitUndoLastCommit => '撤销上次提交';
|
||||
|
||||
@override
|
||||
String get gitUndoLastCommitConfirm => '确定要撤销上一次提交吗?代码更改将保留在暂存区。';
|
||||
|
||||
@override
|
||||
String get gitUndoLastCommitSuccess => '已撤销上一次提交';
|
||||
|
||||
@override
|
||||
String get gitStash => '贮藏';
|
||||
|
||||
@override
|
||||
String get gitStashChanges => '贮藏当前更改';
|
||||
|
||||
@override
|
||||
String get gitStashChangesSuccess => '已将当前更改暂存至贮藏栈';
|
||||
|
||||
@override
|
||||
String get gitStashPop => '恢复最近贮藏 (Pop)';
|
||||
|
||||
@override
|
||||
String get gitStashPopSuccess => '已恢复最近的贮藏更改';
|
||||
|
||||
@override
|
||||
String get gitNoStashFound => '当前没有可恢复的贮藏记录';
|
||||
|
||||
@override
|
||||
String get gitAddToGitignore => '添加到 .gitignore';
|
||||
|
||||
@override
|
||||
String get gitAddedToGitignore => '已添加至 .gitignore';
|
||||
|
||||
@override
|
||||
String get gitMoreActions => '更多操作';
|
||||
|
||||
@override
|
||||
String get gitOpenFile => '打开文件';
|
||||
|
||||
@override
|
||||
String get gitTags => '标签';
|
||||
|
||||
@override
|
||||
String get gitCreateTag => '创建新标签';
|
||||
|
||||
@override
|
||||
String get gitTagNameHint => '输入标签名称 (例如 v1.0.0)';
|
||||
|
||||
@override
|
||||
String get gitTagMessageHint => '标签附注信息 (可选)';
|
||||
|
||||
@override
|
||||
String get gitDeleteTag => '删除标签';
|
||||
|
||||
@override
|
||||
String gitDeleteTagConfirm(String tag) {
|
||||
return '确定要删除本地标签 $tag 吗?';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitCreateTagSuccess(String tag) {
|
||||
return '已创建标签 $tag';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitDeleteTagSuccess(String tag) {
|
||||
return '已删除标签 $tag';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitSwitchTagSuccess(String tag) {
|
||||
return '已检出至标签 $tag';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitNoTags => '暂无标签';
|
||||
|
||||
@override
|
||||
String get gitSelectBranchToDelete => '选择要删除的分支';
|
||||
|
||||
@override
|
||||
String get gitSelectTagToDelete => '选择要删除的标签';
|
||||
|
||||
@override
|
||||
String get gitSearchBranches => '搜索分支...';
|
||||
|
||||
@override
|
||||
String get gitSearchTags => '搜索标签...';
|
||||
|
||||
@override
|
||||
String get gitNoBranches => '暂无分支';
|
||||
|
||||
@override
|
||||
String get gitDiff => '差异对比';
|
||||
|
||||
@override
|
||||
String get gitDiffOriginal => '原始版本';
|
||||
|
||||
@override
|
||||
String get gitDiffModified => '修改版本';
|
||||
|
||||
@override
|
||||
String get gitDiffSplitView => '双屏分栏';
|
||||
|
||||
@override
|
||||
String get gitDiffUnifiedView => '单屏内联';
|
||||
|
||||
@override
|
||||
String get gitDiffPrevChange => '上一处更改';
|
||||
|
||||
@override
|
||||
String get gitDiffNextChange => '下一处更改';
|
||||
|
||||
@override
|
||||
String get gitDiffBinaryOrEmpty => '二进制或不支持比较的文件';
|
||||
|
||||
@override
|
||||
String get gitDiffNoChanges => '该文件与基准版本完全一致,暂无差异';
|
||||
|
||||
@override
|
||||
String get gitDiffStageTooltip => '暂存此文件更改';
|
||||
|
||||
@override
|
||||
String get gitDiffUnstageTooltip => '取消暂存此文件';
|
||||
|
||||
@override
|
||||
String get gitDiffDiscardTooltip => '放弃此文件更改';
|
||||
|
||||
@override
|
||||
String get gitExpandAll => '全部展开';
|
||||
|
||||
@override
|
||||
String gitLoadMoreCommits(int count) {
|
||||
return '加载更多提交 ($count)';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitLoadedCommitsCount(int loaded, int total) {
|
||||
return '已显示 $loaded / $total 个提交';
|
||||
}
|
||||
|
||||
@override
|
||||
String gitAllCommitsLoaded(int count) {
|
||||
return '已显示全部 $count 个提交';
|
||||
}
|
||||
|
||||
@override
|
||||
String get gitLoadingMoreCommits => '正在加载更多提交...';
|
||||
|
||||
@override
|
||||
String get searchExpandAllMatchesInFile => '展开全部匹配项';
|
||||
}
|
||||
@@ -1101,5 +1101,231 @@
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitNotInstalled": "未检测到 Git",
|
||||
"gitNotInstalledDesc": "系统中未检测到 Git 命令行工具。请在系统终端或 Linux 容器中安装 git(如执行 apt update && apt install -y git)。",
|
||||
"gitNeedInstall": "需要安装 Git",
|
||||
"gitInstallAction": "安装 Git",
|
||||
"gitInstallingProgress": "正在安装 Git...",
|
||||
"gitInstallSuccess": "Git 安装成功",
|
||||
"gitInstallFailed": "Git 安装失败: {error}",
|
||||
"@gitInstallFailed": {
|
||||
"placeholders": {
|
||||
"error": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitNoRepoFound": "当前工程尚未初始化为 Git 仓库",
|
||||
"gitNoRepoDesc": "初始化本地 Git 仓库后,即可使用版本控制、分支管理及变更追踪功能。",
|
||||
"gitInitRepo": "初始化 Git 仓库",
|
||||
"gitInitializing": "正在初始化 Git 仓库...",
|
||||
"gitInitSuccess": "Git 仓库初始化成功",
|
||||
"gitInitFailed": "Git 仓库初始化失败: {error}",
|
||||
"@gitInitFailed": {
|
||||
"placeholders": {
|
||||
"error": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitRepository": "仓库",
|
||||
"gitCurrentBranch": "当前分支: {branch}",
|
||||
"@gitCurrentBranch": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitSwitchRepo": "切换仓库",
|
||||
"gitRefresh": "刷新 Git 状态",
|
||||
"gitChanges": "更改",
|
||||
"gitStagedChanges": "暂存的更改",
|
||||
"gitNoChanges": "暂无任何文件更改",
|
||||
"gitStatusUntracked": "未跟踪",
|
||||
"gitStatusModified": "已修改",
|
||||
"gitStatusAdded": "新增",
|
||||
"gitStatusDeleted": "已删除",
|
||||
"gitStatusRenamed": "重命名",
|
||||
"gitStatusConflict": "冲突",
|
||||
"gitMultipleReposDetected": "检测到多个 Git 仓库 ({count})",
|
||||
"@gitMultipleReposDetected": {
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitStageChange": "暂存更改",
|
||||
"gitUnstageChange": "取消暂存更改",
|
||||
"gitStageAll": "全部暂存更改",
|
||||
"gitUnstageAll": "全部取消暂存更改",
|
||||
"gitStageSuccess": "已暂存",
|
||||
"gitUnstageSuccess": "已取消暂存",
|
||||
"gitCommit": "提交",
|
||||
"gitCommitMessageHint": "提交信息",
|
||||
"gitCommitSuccess": "提交成功",
|
||||
"gitCommitFailed": "提交失败: {error}",
|
||||
"@gitCommitFailed": {
|
||||
"placeholders": {
|
||||
"error": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDiscardChange": "放弃更改",
|
||||
"gitDiscardConfirm": "放弃更改?",
|
||||
"gitDiscardConfirmDesc": "确定要放弃对 \"{fileName}\" 的所有未暂存更改吗?此操作无法撤销。",
|
||||
"@gitDiscardConfirmDesc": {
|
||||
"placeholders": {
|
||||
"fileName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitNoCommitMessage": "请输入提交信息",
|
||||
"gitNoStagedChangesToCommit": "暂存区没有已暂存的更改,是否全部暂存并直接提交?",
|
||||
"gitStageAllAndCommit": "全部暂存并提交",
|
||||
"gitGraphTitle": "图表",
|
||||
"gitNoCommits": "暂无提交历史",
|
||||
"gitCommitDetails": "提交详情",
|
||||
"gitCommitAuthor": "作者",
|
||||
"gitCommitDate": "提交日期",
|
||||
"gitCommitHash": "提交哈希",
|
||||
"gitCopyHash": "复制哈希",
|
||||
"gitHashCopied": "已复制提交哈希到剪贴板",
|
||||
"gitCommitParent": "父提交",
|
||||
"gitDiscardAll": "全部放弃更改",
|
||||
"gitDiscardAllChangesTitle": "放弃所有未暂存更改?",
|
||||
"gitDiscardAllChangesConfirm": "确定要放弃所有未暂存更改吗?所有已修改的文件将恢复,未跟踪的新文件将被清除,此操作无法撤销。",
|
||||
"gitDiscardAllStagedTitle": "放弃所有已暂存更改?",
|
||||
"gitDiscardAllStagedConfirm": "确定要放弃所有已暂存的更改吗?所选文件的修改将被彻底恢复,此操作无法撤销。",
|
||||
"gitBranches": "分支",
|
||||
"gitCreateBranch": "创建新分支",
|
||||
"gitBranchNameHint": "输入新分支名称",
|
||||
"gitSwitchBranchSuccess": "已切换至分支 {branch}",
|
||||
"@gitSwitchBranchSuccess": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitCreateBranchSuccess": "已创建并切换至新分支 {branch}",
|
||||
"@gitCreateBranchSuccess": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDeleteBranch": "删除分支",
|
||||
"gitDeleteBranchConfirm": "确定要删除本地分支 {branch} 吗?",
|
||||
"@gitDeleteBranchConfirm": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDeleteBranchSuccess": "已删除分支 {branch}",
|
||||
"@gitDeleteBranchSuccess": {
|
||||
"placeholders": {
|
||||
"branch": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitCannotDeleteCurrentBranch": "无法删除当前所在分支",
|
||||
"gitUndoLastCommit": "撤销上次提交",
|
||||
"gitUndoLastCommitConfirm": "确定要撤销上一次提交吗?代码更改将保留在暂存区。",
|
||||
"gitUndoLastCommitSuccess": "已撤销上一次提交",
|
||||
"gitStash": "贮藏",
|
||||
"gitStashChanges": "贮藏当前更改",
|
||||
"gitStashChangesSuccess": "已将当前更改暂存至贮藏栈",
|
||||
"gitStashPop": "恢复最近贮藏 (Pop)",
|
||||
"gitStashPopSuccess": "已恢复最近的贮藏更改",
|
||||
"gitNoStashFound": "当前没有可恢复的贮藏记录",
|
||||
"gitAddToGitignore": "添加到 .gitignore",
|
||||
"gitAddedToGitignore": "已添加至 .gitignore",
|
||||
"gitMoreActions": "更多操作",
|
||||
"gitOpenFile": "打开文件",
|
||||
"gitTags": "标签",
|
||||
"gitCreateTag": "创建新标签",
|
||||
"gitTagNameHint": "输入标签名称 (例如 v1.0.0)",
|
||||
"gitTagMessageHint": "标签附注信息 (可选)",
|
||||
"gitDeleteTag": "删除标签",
|
||||
"gitDeleteTagConfirm": "确定要删除本地标签 {tag} 吗?",
|
||||
"@gitDeleteTagConfirm": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitCreateTagSuccess": "已创建标签 {tag}",
|
||||
"@gitCreateTagSuccess": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitDeleteTagSuccess": "已删除标签 {tag}",
|
||||
"@gitDeleteTagSuccess": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitSwitchTagSuccess": "已检出至标签 {tag}",
|
||||
"@gitSwitchTagSuccess": {
|
||||
"placeholders": {
|
||||
"tag": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitNoTags": "暂无标签",
|
||||
"gitSelectBranchToDelete": "选择要删除的分支",
|
||||
"gitSelectTagToDelete": "选择要删除的标签",
|
||||
"gitSearchBranches": "搜索分支...",
|
||||
"gitSearchTags": "搜索标签...",
|
||||
"gitNoBranches": "暂无分支",
|
||||
"gitDiff": "差异对比",
|
||||
"gitDiffOriginal": "原始版本",
|
||||
"gitDiffModified": "修改版本",
|
||||
"gitDiffSplitView": "双屏分栏",
|
||||
"gitDiffUnifiedView": "单屏内联",
|
||||
"gitDiffPrevChange": "上一处更改",
|
||||
"gitDiffNextChange": "下一处更改",
|
||||
"gitDiffBinaryOrEmpty": "二进制或不支持比较的文件",
|
||||
"gitDiffNoChanges": "该文件与基准版本完全一致,暂无差异",
|
||||
"gitDiffStageTooltip": "暂存此文件更改",
|
||||
"gitDiffUnstageTooltip": "取消暂存此文件",
|
||||
"gitDiffDiscardTooltip": "放弃此文件更改",
|
||||
"gitExpandAll": "全部展开",
|
||||
"gitLoadMoreCommits": "加载更多提交 ({count})",
|
||||
"@gitLoadMoreCommits": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"gitLoadedCommitsCount": "已显示 {loaded} / {total} 个提交",
|
||||
"@gitLoadedCommitsCount": {
|
||||
"placeholders": {
|
||||
"loaded": { "type": "int" },
|
||||
"total": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"gitAllCommitsLoaded": "已显示全部 {count} 个提交",
|
||||
"@gitAllCommitsLoaded": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"gitLoadingMoreCommits": "正在加载更多提交...",
|
||||
"searchExpandAllMatchesInFile": "展开全部匹配项"
|
||||
}
|
||||
+10
-8
@@ -42,21 +42,23 @@ class MyApp extends StatelessWidget {
|
||||
return pp;
|
||||
},
|
||||
),
|
||||
ChangeNotifierProxyProvider<ProjectProvider, TabProvider>(
|
||||
ChangeNotifierProxyProvider<ProjectProvider, GitProvider>(
|
||||
create: (_) => GitProvider(),
|
||||
update: (_, project, git) =>
|
||||
(git ?? GitProvider())..bindRootPath(project.rootPath),
|
||||
),
|
||||
ChangeNotifierProxyProvider2<ProjectProvider, GitProvider, TabProvider>(
|
||||
create: (_) => TabProvider()..init(),
|
||||
update: (_, project, tab) =>
|
||||
(tab ?? (TabProvider()..init()))..bindProjectProvider(project),
|
||||
update: (_, project, git, tab) =>
|
||||
(tab ?? (TabProvider()..init()))
|
||||
..bindProjectProvider(project)
|
||||
..bindGitProvider(git),
|
||||
),
|
||||
ChangeNotifierProxyProvider<ProjectProvider, SearchProvider>(
|
||||
create: (_) => SearchProvider(),
|
||||
update: (_, project, search) =>
|
||||
(search ?? SearchProvider())..bindRootPath(project.rootPath),
|
||||
),
|
||||
ChangeNotifierProxyProvider<ProjectProvider, GitProvider>(
|
||||
create: (_) => GitProvider(),
|
||||
update: (_, project, git) =>
|
||||
(git ?? GitProvider())..bindRootPath(project.rootPath),
|
||||
),
|
||||
ChangeNotifierProvider(create: (_) => TerminalProvider()),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) {
|
||||
|
||||
@@ -100,3 +100,68 @@ class GitCommandResult {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Git 提交记录与图表节点模型
|
||||
class GitCommit {
|
||||
final String hash;
|
||||
final String shortHash;
|
||||
final List<String> parentHashes;
|
||||
final String authorName;
|
||||
final String authorEmail;
|
||||
final DateTime authorDate;
|
||||
final String relativeDate;
|
||||
final String subject;
|
||||
final List<String> refs; // e.g. ["HEAD -> main", "origin/main", "tag: v1.0.0"]
|
||||
|
||||
/// 线性图表拓扑布局字段
|
||||
final int lane; // 列通道索引 (0, 1, 2...)
|
||||
final List<int> activeLanes; // 经过当前行的活跃通道列表
|
||||
final List<int> outgoingLanes; // 当前节点连接向父节点的通道列表
|
||||
|
||||
const GitCommit({
|
||||
required this.hash,
|
||||
required this.shortHash,
|
||||
required this.parentHashes,
|
||||
required this.authorName,
|
||||
required this.authorEmail,
|
||||
required this.authorDate,
|
||||
required this.relativeDate,
|
||||
required this.subject,
|
||||
this.refs = const [],
|
||||
this.lane = 0,
|
||||
this.activeLanes = const [],
|
||||
this.outgoingLanes = const [],
|
||||
});
|
||||
|
||||
bool get isHead => refs.any((r) => r.startsWith('HEAD'));
|
||||
|
||||
GitCommit copyWith({
|
||||
String? hash,
|
||||
String? shortHash,
|
||||
List<String>? parentHashes,
|
||||
String? authorName,
|
||||
String? authorEmail,
|
||||
DateTime? authorDate,
|
||||
String? relativeDate,
|
||||
String? subject,
|
||||
List<String>? refs,
|
||||
int? lane,
|
||||
List<int>? activeLanes,
|
||||
List<int>? outgoingLanes,
|
||||
}) {
|
||||
return GitCommit(
|
||||
hash: hash ?? this.hash,
|
||||
shortHash: shortHash ?? this.shortHash,
|
||||
parentHashes: parentHashes ?? this.parentHashes,
|
||||
authorName: authorName ?? this.authorName,
|
||||
authorEmail: authorEmail ?? this.authorEmail,
|
||||
authorDate: authorDate ?? this.authorDate,
|
||||
relativeDate: relativeDate ?? this.relativeDate,
|
||||
subject: subject ?? this.subject,
|
||||
refs: refs ?? this.refs,
|
||||
lane: lane ?? this.lane,
|
||||
activeLanes: activeLanes ?? this.activeLanes,
|
||||
outgoingLanes: outgoingLanes ?? this.outgoingLanes,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import '../models/git_model.dart';
|
||||
import '../services/git_service.dart';
|
||||
import '../utils/git_decoration_utils.dart';
|
||||
|
||||
/// Git 状态管理 Provider
|
||||
class GitProvider extends ChangeNotifier {
|
||||
final GitService _gitService;
|
||||
|
||||
GitProvider({GitService? gitService}) : _gitService = gitService ?? GitService.instance;
|
||||
|
||||
String? _rootPath;
|
||||
List<GitRepositoryInfo> _repositories = [];
|
||||
String? _currentRepoPath;
|
||||
bool _gitInstalled = true;
|
||||
String? _gitVersion;
|
||||
bool _isLoading = false;
|
||||
bool _isInitializing = false;
|
||||
bool _isInstallingGit = false;
|
||||
String? _errorMessage;
|
||||
List<GitFileStatus> _changedFiles = [];
|
||||
Map<String, GitFileStatus> _fileStatusMap = {};
|
||||
Map<String, GitFileStatusType> _dirStatusMap = {};
|
||||
String? _currentBranch;
|
||||
List<String> _branches = [];
|
||||
List<String> _tags = [];
|
||||
List<GitCommit> _commits = [];
|
||||
int _stashCount = 0;
|
||||
int _totalCommitsCount = 0;
|
||||
int _commitsLimit = 50;
|
||||
bool _isLoadingMoreCommits = false;
|
||||
|
||||
// UI 内存状态缓存(保留折叠状态、输入框草稿与滚动位置)
|
||||
bool _stagedExpanded = true;
|
||||
bool _unstagedExpanded = true;
|
||||
bool _graphExpanded = true;
|
||||
bool _showTagsInSelector = false;
|
||||
String _commitMessage = '';
|
||||
double _scrollOffset = 0.0;
|
||||
bool _isCurrentRefTag = false;
|
||||
|
||||
// Getters
|
||||
GitService get gitService => _gitService;
|
||||
String? get rootPath => _rootPath;
|
||||
List<GitRepositoryInfo> get repositories => List.unmodifiable(_repositories);
|
||||
String? get currentRepoPath => _currentRepoPath;
|
||||
bool get gitInstalled => _gitInstalled;
|
||||
String? get gitVersion => _gitVersion;
|
||||
bool get isLoading => _isLoading;
|
||||
bool get isInitializing => _isInitializing;
|
||||
bool get isInstallingGit => _isInstallingGit;
|
||||
String? get errorMessage => _errorMessage;
|
||||
List<GitFileStatus> get changedFiles => List.unmodifiable(_changedFiles);
|
||||
String? get currentBranch => _currentBranch;
|
||||
bool get isCurrentRefTag => _isCurrentRefTag;
|
||||
List<String> get branches => List.unmodifiable(_branches);
|
||||
List<String> get tags => List.unmodifiable(_tags);
|
||||
List<GitCommit> get commits => List.unmodifiable(_commits);
|
||||
int get stashCount => _stashCount;
|
||||
int get totalCommitsCount => _totalCommitsCount;
|
||||
int get commitsLimit => _commitsLimit;
|
||||
bool get isLoadingMoreCommits => _isLoadingMoreCommits;
|
||||
bool get hasMoreCommits => _totalCommitsCount > 0 ? _commits.length < _totalCommitsCount : false;
|
||||
|
||||
bool get stagedExpanded => _stagedExpanded;
|
||||
bool get unstagedExpanded => _unstagedExpanded;
|
||||
bool get graphExpanded => _graphExpanded;
|
||||
bool get showTagsInSelector => _showTagsInSelector;
|
||||
String get commitMessage => _commitMessage;
|
||||
double get scrollOffset => _scrollOffset;
|
||||
|
||||
void setStagedExpanded(bool val) => _stagedExpanded = val;
|
||||
void setUnstagedExpanded(bool val) => _unstagedExpanded = val;
|
||||
void setGraphExpanded(bool val) => _graphExpanded = val;
|
||||
void setShowTagsInSelector(bool val) => _showTagsInSelector = val;
|
||||
void setCommitMessage(String val) => _commitMessage = val;
|
||||
void setScrollOffset(double val) => _scrollOffset = val;
|
||||
|
||||
bool get hasProject => _rootPath != null && _rootPath!.trim().isNotEmpty;
|
||||
bool get hasRepository => _repositories.isNotEmpty;
|
||||
bool get isGitRepo => hasRepository;
|
||||
|
||||
GitRepositoryInfo? get currentRepo {
|
||||
if (_currentRepoPath == null) return null;
|
||||
return _repositories.where((r) => r.rootPath == _currentRepoPath).firstOrNull;
|
||||
}
|
||||
|
||||
/// 暂存区文件列表
|
||||
List<GitFileStatus> get stagedFiles => _changedFiles.where((f) => f.isStaged).toList();
|
||||
|
||||
/// 未暂存文件列表(含修改与未跟踪)
|
||||
List<GitFileStatus> get unstagedFiles => _changedFiles.where((f) => !f.isStaged).toList();
|
||||
|
||||
/// 总变动文件数量(供活动栏与角标展示)
|
||||
int get totalChangedCount => _changedFiles.length;
|
||||
|
||||
/// 根据文件绝对路径或相对路径 O(1) 获取 Git 变更状态(用于文件树文件名染色与字母标识)
|
||||
GitFileStatus? getFileStatus(String filePath) {
|
||||
if (_fileStatusMap.isEmpty) return null;
|
||||
final normalized = p.normalize(filePath);
|
||||
final direct = _fileStatusMap[normalized];
|
||||
if (direct != null) return direct;
|
||||
return _fileStatusMap[normalized.toLowerCase()];
|
||||
}
|
||||
|
||||
/// 根据目录绝对路径 O(1) 获取最高优先级 Git 变更状态类别(用于文件夹名称染色与彩色圆点)
|
||||
GitFileStatusType? getDirectoryStatus(String dirPath) {
|
||||
if (_dirStatusMap.isEmpty) return null;
|
||||
final normalized = p.normalize(dirPath);
|
||||
final direct = _dirStatusMap[normalized];
|
||||
if (direct != null) return direct;
|
||||
return _dirStatusMap[normalized.toLowerCase()];
|
||||
}
|
||||
|
||||
/// 绑定项目根路径(响应 ProjectProvider 切换)
|
||||
void bindRootPath(String? newRootPath) {
|
||||
final normalized = newRootPath != null && newRootPath.trim().isNotEmpty
|
||||
? p.normalize(newRootPath.trim())
|
||||
: null;
|
||||
|
||||
if (_rootPath != normalized) {
|
||||
_rootPath = normalized;
|
||||
_repositories = [];
|
||||
_currentRepoPath = null;
|
||||
_changedFiles = [];
|
||||
_rebuildStatusMaps();
|
||||
_currentBranch = null;
|
||||
_branches = [];
|
||||
_tags = [];
|
||||
_commits = [];
|
||||
_stashCount = 0;
|
||||
_errorMessage = null;
|
||||
|
||||
if (_rootPath != null) {
|
||||
refresh();
|
||||
} else {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int _refreshSeq = 0;
|
||||
|
||||
/// 刷新 Git 状态与仓库信息
|
||||
Future<void> refresh() async {
|
||||
final seq = ++_refreshSeq;
|
||||
|
||||
if (_rootPath == null || _rootPath!.isEmpty) {
|
||||
_repositories = [];
|
||||
_currentRepoPath = null;
|
||||
_changedFiles = [];
|
||||
_rebuildStatusMaps();
|
||||
_currentBranch = null;
|
||||
_branches = [];
|
||||
_tags = [];
|
||||
_commits = [];
|
||||
_stashCount = 0;
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
// 1. 校验 Git 命令行工具环境
|
||||
final env = await _gitService.checkGitInstalled();
|
||||
if (seq != _refreshSeq) return;
|
||||
|
||||
_gitInstalled = env.isInstalled;
|
||||
_gitVersion = env.version;
|
||||
if (!env.isInstalled) {
|
||||
_errorMessage = env.errorMessage ?? '未检测到 Git 命令行工具';
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 探测工程根目录及子目录下的仓库列表
|
||||
final detected = await _gitService.detectRepositories(_rootPath!);
|
||||
if (seq != _refreshSeq) return;
|
||||
|
||||
_repositories = detected;
|
||||
|
||||
// 3. 确定当前活跃选中的仓库
|
||||
if (_repositories.isNotEmpty) {
|
||||
// 如果当前没有选中或先前选中的已不存在,优先选根仓库,否则选第 1 个
|
||||
if (_currentRepoPath == null || !_repositories.any((r) => r.rootPath == _currentRepoPath)) {
|
||||
final rootRepo = _repositories.where((r) => r.isRoot).firstOrNull;
|
||||
_currentRepoPath = rootRepo != null ? rootRepo.rootPath : _repositories.first.rootPath;
|
||||
}
|
||||
|
||||
// 4. 加载当前活跃仓库的状态与分支
|
||||
await _loadCurrentRepoDetails();
|
||||
if (seq != _refreshSeq) return;
|
||||
} else {
|
||||
_currentRepoPath = null;
|
||||
_changedFiles = [];
|
||||
_rebuildStatusMaps();
|
||||
_currentBranch = null;
|
||||
}
|
||||
} catch (e) {
|
||||
if (seq == _refreshSeq) {
|
||||
_errorMessage = '加载 Git 状态异常: $e';
|
||||
}
|
||||
} finally {
|
||||
if (seq == _refreshSeq) {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换当前选中的活跃仓库
|
||||
Future<void> switchRepository(String repoPath) async {
|
||||
final normalized = p.normalize(repoPath);
|
||||
if (_currentRepoPath == normalized) return;
|
||||
|
||||
if (_repositories.any((r) => r.rootPath == normalized)) {
|
||||
_currentRepoPath = normalized;
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
|
||||
await _loadCurrentRepoDetails();
|
||||
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 初始化本地 Git 仓库
|
||||
Future<GitCommandResult> initRepository({
|
||||
String? targetPath,
|
||||
String defaultBranch = 'main',
|
||||
}) async {
|
||||
final path = targetPath ?? _rootPath;
|
||||
if (path == null || path.isEmpty) {
|
||||
return GitCommandResult.error('未指定有效的仓库初始化路径');
|
||||
}
|
||||
|
||||
_isInitializing = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final result = await _gitService.initRepository(
|
||||
path,
|
||||
defaultBranch: defaultBranch,
|
||||
);
|
||||
|
||||
if (result.success) {
|
||||
// 初始化成功后自动重新扫描并选中该仓库
|
||||
await refresh();
|
||||
} else {
|
||||
_errorMessage = result.stderr.isNotEmpty ? result.stderr : '初始化 Git 仓库失败';
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
_errorMessage = '初始化异常: $e';
|
||||
return GitCommandResult.error(e.toString());
|
||||
} finally {
|
||||
_isInitializing = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 安装 Git
|
||||
Future<GitCommandResult> installGit({void Function(String output)? onProgress}) async {
|
||||
_isInstallingGit = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final result = await _gitService.installGit(onProgress: onProgress);
|
||||
if (result.success) {
|
||||
await refresh();
|
||||
} else {
|
||||
_errorMessage = result.stderr.isNotEmpty ? result.stderr : '安装 Git 失败';
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
_errorMessage = '安装 Git 异常: $e';
|
||||
return GitCommandResult.error(e.toString());
|
||||
} finally {
|
||||
_isInstallingGit = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 暂存指定文件
|
||||
Future<GitCommandResult> stageFile(String relativePath) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.stageFile(_currentRepoPath!, relativePath);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 取消暂存指定文件
|
||||
Future<GitCommandResult> unstageFile(String relativePath) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.unstageFile(_currentRepoPath!, relativePath);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 全部暂存
|
||||
Future<GitCommandResult> stageAll() async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.stageAll(_currentRepoPath!);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 全部取消暂存
|
||||
Future<GitCommandResult> unstageAll() async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.unstageAll(_currentRepoPath!);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 放弃单个文件的更改
|
||||
Future<GitCommandResult> discardFile(GitFileStatus file) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final isUntracked = file.statusType == GitFileStatusType.untracked;
|
||||
final res = await _gitService.discardFile(
|
||||
_currentRepoPath!,
|
||||
file.relativePath,
|
||||
isUntracked: isUntracked,
|
||||
isStaged: file.isStaged,
|
||||
);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 全部放弃未暂存更改
|
||||
Future<GitCommandResult> discardAllUnstaged() async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.discardAllUnstaged(_currentRepoPath!);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 全部放弃已暂存更改
|
||||
Future<GitCommandResult> discardAllStaged() async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.discardAllStaged(_currentRepoPath!);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 提交当前暂存区的更改
|
||||
Future<GitCommandResult> commit(String message, {bool amend = false}) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.commit(_currentRepoPath!, message, amend: amend);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 切换分支
|
||||
Future<GitCommandResult> switchBranch(String branchName) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.checkoutBranch(_currentRepoPath!, branchName);
|
||||
if (res.success) {
|
||||
_currentBranch = branchName;
|
||||
_isCurrentRefTag = false;
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 创建并可选检出新分支
|
||||
Future<GitCommandResult> createBranch(String branchName, {bool checkout = true}) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.createBranch(_currentRepoPath!, branchName, checkout: checkout);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 删除本地分支
|
||||
Future<GitCommandResult> deleteBranch(String branchName, {bool force = false}) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.deleteBranch(_currentRepoPath!, branchName, force: force);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 撤销上一次提交
|
||||
Future<GitCommandResult> undoLastCommit() async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.undoLastCommit(_currentRepoPath!);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 贮藏当前更改
|
||||
Future<GitCommandResult> stash({String? message}) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.stash(_currentRepoPath!, message: message);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 恢复最近贮藏
|
||||
Future<GitCommandResult> stashPop() async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.stashPop(_currentRepoPath!);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 添加文件到 .gitignore
|
||||
Future<bool> addToGitignore(String relativePath) async {
|
||||
if (_currentRepoPath == null) return false;
|
||||
final success = await _gitService.addToGitignore(_currentRepoPath!, relativePath);
|
||||
if (success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/// 创建新标签
|
||||
Future<GitCommandResult> createTag(String tagName, {String? message}) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.createTag(_currentRepoPath!, tagName, message: message);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 删除本地标签
|
||||
Future<GitCommandResult> deleteTag(String tagName) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.deleteTag(_currentRepoPath!, tagName);
|
||||
if (res.success) {
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 检出指定标签
|
||||
Future<GitCommandResult> switchTag(String tagName) async {
|
||||
if (_currentRepoPath == null) return GitCommandResult.error('未选择仓库');
|
||||
final res = await _gitService.checkoutTag(_currentRepoPath!, tagName);
|
||||
if (res.success) {
|
||||
_currentBranch = tagName;
|
||||
_isCurrentRefTag = true;
|
||||
await _loadCurrentRepoDetails();
|
||||
notifyListeners();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// 分页加载更多提交历史
|
||||
Future<void> loadMoreCommits({int count = 50}) async {
|
||||
if (_currentRepoPath == null || _isLoadingMoreCommits) return;
|
||||
_isLoadingMoreCommits = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
_commitsLimit += count;
|
||||
_commits = await _gitService.getLog(_currentRepoPath!, maxCount: _commitsLimit);
|
||||
if (_commits.length > _totalCommitsCount) {
|
||||
_totalCommitsCount = _commits.length;
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('[GitProvider] 加载更多提交异常: $e');
|
||||
} finally {
|
||||
_isLoadingMoreCommits = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 全量加载所有提交历史并解除分页限制
|
||||
Future<void> loadAllCommits() async {
|
||||
if (_currentRepoPath == null || _isLoadingMoreCommits) return;
|
||||
_isLoadingMoreCommits = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
final target = _totalCommitsCount > 0 ? _totalCommitsCount : 2000;
|
||||
_commitsLimit = target;
|
||||
_commits = await _gitService.getLog(_currentRepoPath!, maxCount: _commitsLimit);
|
||||
_totalCommitsCount = _commits.length;
|
||||
} catch (e) {
|
||||
debugPrint('[GitProvider] 全量加载提交异常: $e');
|
||||
} finally {
|
||||
_isLoadingMoreCommits = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 内部辅助:加载当前仓库的分支、提交历史与文件变更列表
|
||||
Future<void> _loadCurrentRepoDetails() async {
|
||||
if (_currentRepoPath == null) return;
|
||||
try {
|
||||
final refInfo = await _gitService.getCurrentRefInfo(_currentRepoPath!);
|
||||
_currentBranch = refInfo.name;
|
||||
_isCurrentRefTag = refInfo.isTag;
|
||||
_branches = await _gitService.getLocalBranches(_currentRepoPath!);
|
||||
_tags = await _gitService.getTags(_currentRepoPath!);
|
||||
_changedFiles = await _gitService.getGitStatus(_currentRepoPath!);
|
||||
_rebuildStatusMaps();
|
||||
_commitsLimit = 50;
|
||||
_totalCommitsCount = await _gitService.getTotalCommitsCount(_currentRepoPath!);
|
||||
_commits = await _gitService.getLog(_currentRepoPath!, maxCount: _commitsLimit);
|
||||
if (_commits.length > _totalCommitsCount) {
|
||||
_totalCommitsCount = _commits.length;
|
||||
}
|
||||
_stashCount = await _gitService.getStashCount(_currentRepoPath!);
|
||||
|
||||
// 同步更新 repositories 列表中当前项的分支信息
|
||||
final idx = _repositories.indexWhere((r) => r.rootPath == _currentRepoPath);
|
||||
if (idx != -1) {
|
||||
_repositories[idx] = _repositories[idx].copyWith(currentBranch: _currentBranch);
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('[GitProvider] 加载仓库详情异常: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// 预先计算文件和目录的 Git 状态映射,将文件树每帧查询时间复杂度从 O(N*M) 降至 O(1)
|
||||
void _rebuildStatusMaps() {
|
||||
final fileMap = <String, GitFileStatus>{};
|
||||
final dirMap = <String, GitFileStatusType>{};
|
||||
|
||||
for (final file in _changedFiles) {
|
||||
final normalizedFilePath = p.normalize(file.path);
|
||||
fileMap[normalizedFilePath] = file;
|
||||
fileMap[normalizedFilePath.toLowerCase()] = file;
|
||||
|
||||
// 自底向上聚合所有祖先目录状态(高优先级覆盖低优先级)
|
||||
var currentDir = p.dirname(normalizedFilePath);
|
||||
while (currentDir.isNotEmpty && currentDir != '.' && currentDir != p.dirname(currentDir)) {
|
||||
final currentType = dirMap[currentDir];
|
||||
if (currentType == null ||
|
||||
GitDecorationUtils.getPriority(file.statusType) >
|
||||
GitDecorationUtils.getPriority(currentType)) {
|
||||
dirMap[currentDir] = file.statusType;
|
||||
dirMap[currentDir.toLowerCase()] = file.statusType;
|
||||
}
|
||||
|
||||
// 避免向上越界超出仓库根目录或项目根目录
|
||||
if (_currentRepoPath != null &&
|
||||
(currentDir == p.normalize(_currentRepoPath!) ||
|
||||
currentDir.toLowerCase() == p.normalize(_currentRepoPath!).toLowerCase())) {
|
||||
break;
|
||||
}
|
||||
if (_rootPath != null &&
|
||||
(currentDir == p.normalize(_rootPath!) ||
|
||||
currentDir.toLowerCase() == p.normalize(_rootPath!).toLowerCase())) {
|
||||
break;
|
||||
}
|
||||
final parent = p.dirname(currentDir);
|
||||
if (parent == currentDir) break;
|
||||
currentDir = parent;
|
||||
}
|
||||
}
|
||||
|
||||
_fileStatusMap = fileMap;
|
||||
_dirStatusMap = dirMap;
|
||||
}
|
||||
|
||||
/// 测试辅助方法
|
||||
@visibleForTesting
|
||||
void setStateForTesting({
|
||||
String? rootPath,
|
||||
List<GitRepositoryInfo>? repositories,
|
||||
String? currentRepoPath,
|
||||
bool? gitInstalled,
|
||||
bool? isLoading,
|
||||
bool? isInitializing,
|
||||
List<GitFileStatus>? changedFiles,
|
||||
String? currentBranch,
|
||||
bool? isCurrentRefTag,
|
||||
List<String>? branches,
|
||||
List<String>? tags,
|
||||
List<GitCommit>? commits,
|
||||
int? stashCount,
|
||||
int? totalCommitsCount,
|
||||
int? commitsLimit,
|
||||
String? errorMessage,
|
||||
bool? stagedExpanded,
|
||||
bool? unstagedExpanded,
|
||||
bool? graphExpanded,
|
||||
bool? showTagsInSelector,
|
||||
String? commitMessage,
|
||||
double? scrollOffset,
|
||||
}) {
|
||||
if (rootPath != null) _rootPath = rootPath;
|
||||
if (repositories != null) _repositories = repositories;
|
||||
if (currentRepoPath != null) _currentRepoPath = currentRepoPath;
|
||||
if (gitInstalled != null) _gitInstalled = gitInstalled;
|
||||
if (isLoading != null) _isLoading = isLoading;
|
||||
if (isInitializing != null) _isInitializing = isInitializing;
|
||||
if (changedFiles != null) {
|
||||
_changedFiles = changedFiles;
|
||||
_rebuildStatusMaps();
|
||||
}
|
||||
if (currentBranch != null) _currentBranch = currentBranch;
|
||||
if (isCurrentRefTag != null) _isCurrentRefTag = isCurrentRefTag;
|
||||
if (branches != null) _branches = branches;
|
||||
if (tags != null) _tags = tags;
|
||||
if (commits != null) {
|
||||
_commits = commits;
|
||||
if (totalCommitsCount == null) {
|
||||
_totalCommitsCount = commits.length;
|
||||
}
|
||||
}
|
||||
if (stashCount != null) _stashCount = stashCount;
|
||||
if (totalCommitsCount != null) _totalCommitsCount = totalCommitsCount;
|
||||
if (commitsLimit != null) _commitsLimit = commitsLimit;
|
||||
if (errorMessage != null) _errorMessage = errorMessage;
|
||||
if (stagedExpanded != null) _stagedExpanded = stagedExpanded;
|
||||
if (unstagedExpanded != null) _unstagedExpanded = unstagedExpanded;
|
||||
if (graphExpanded != null) _graphExpanded = graphExpanded;
|
||||
if (showTagsInSelector != null) _showTagsInSelector = showTagsInSelector;
|
||||
if (commitMessage != null) _commitMessage = commitMessage;
|
||||
if (scrollOffset != null) _scrollOffset = scrollOffset;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,22 @@ class SearchProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 一键解除分页限制,加载/展示全部匹配文件
|
||||
void loadAllFiles() {
|
||||
if (_result.fileResults.isNotEmpty) {
|
||||
_displayedFilesLimit = _result.fileResults.length;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 展开指定文件并加载展示其全部匹配行
|
||||
void expandAndLoadAllMatchesForFile(FileSearchResult fileResult) {
|
||||
fileResult.isExpanded = true;
|
||||
_fileExpandedStates[fileResult.filePath] = true;
|
||||
_displayedMatchesLimits[fileResult.filePath] = fileResult.matches.length;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int getFileMatchesLimit(String filePath, int defaultSize) {
|
||||
return _displayedMatchesLimits[filePath] ?? defaultSize;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/models/editor_tab_item.dart';
|
||||
import 'package:code_editor/models/file_item.dart';
|
||||
import 'package:code_editor/providers/git_provider.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/services/project_history_service.dart';
|
||||
import 'package:code_editor/services/file_service.dart';
|
||||
@@ -74,6 +75,12 @@ class TabProvider extends ChangeNotifier {
|
||||
projectProvider.onExternalFileDeleted = handleExternalFileDeleted;
|
||||
}
|
||||
|
||||
GitProvider? _gitProvider;
|
||||
|
||||
void bindGitProvider(GitProvider gitProvider) {
|
||||
_gitProvider = gitProvider;
|
||||
}
|
||||
|
||||
bool isFileSelected(String path) {
|
||||
if (_activeFilePath == null) return false;
|
||||
return p.equals(_activeFilePath!, path);
|
||||
@@ -451,6 +458,7 @@ class TabProvider extends ChangeNotifier {
|
||||
tab.originalContent = tab.content;
|
||||
tab.isModified = false;
|
||||
_isModified = false;
|
||||
_gitProvider?.refresh();
|
||||
notifyListeners();
|
||||
}
|
||||
return ok;
|
||||
@@ -462,6 +470,7 @@ class TabProvider extends ChangeNotifier {
|
||||
if (_activeFilePath != null && p.equals(tab.path, _activeFilePath!)) {
|
||||
_isModified = false;
|
||||
}
|
||||
_gitProvider?.refresh();
|
||||
notifyListeners();
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import '../../models/distro_manifest.dart';
|
||||
import '../../models/notice_item.dart';
|
||||
import '../distro_manager.dart';
|
||||
import '../internal_engine_service.dart';
|
||||
import '../toolchain_service.dart';
|
||||
import 'background_task.dart';
|
||||
|
||||
/// Ubuntu APT 软件包安装与卸载任务
|
||||
@@ -74,12 +75,10 @@ class AptPackageTask extends BackgroundTask<bool> {
|
||||
final rootfs = await engine.getRootfsDir();
|
||||
|
||||
final cmd = isUninstall
|
||||
? 'export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true; '
|
||||
'dpkg --configure -a 2>/dev/null || true; '
|
||||
? '${ToolchainService.dpkgAutoHealPrefix} '
|
||||
'apt-get remove --purge -y ${packageName.trim()} && '
|
||||
'apt-get autoremove -y'
|
||||
: 'export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true; '
|
||||
'dpkg --configure -a 2>/dev/null || true; '
|
||||
: '${ToolchainService.dpkgAutoHealPrefix} '
|
||||
'apt-get update && '
|
||||
'apt-get install -y --no-install-recommends ${packageName.trim()}';
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,7 @@ import '../widgets/distro_extract_dialog.dart';
|
||||
import 'distro_installer.dart';
|
||||
import 'distro_manager.dart';
|
||||
import 'lsp/lsp_manager.dart';
|
||||
import 'toolchain_service.dart';
|
||||
|
||||
/// 代码智能与运行时引擎服务(基于统一主系统 Ubuntu 24.04)
|
||||
class InternalEngineService extends ChangeNotifier {
|
||||
@@ -197,8 +198,7 @@ class InternalEngineService extends ChangeNotifier {
|
||||
try {
|
||||
final rootfs = await getRootfsDir();
|
||||
final installCmd =
|
||||
'export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true; '
|
||||
'dpkg --configure -a 2>/dev/null || true; '
|
||||
'${ToolchainService.dpkgAutoHealPrefix} '
|
||||
'apt-get update && '
|
||||
'apt-get install -y --no-install-recommends ${packageName.trim()}';
|
||||
|
||||
@@ -216,6 +216,30 @@ class InternalEngineService extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 自动诊断与修复 dpkg 锁及半安装 (reinstreq/half-installed) 死锁状态
|
||||
Future<bool> repairDpkgStatus({void Function(String chunk)? onOutput}) async {
|
||||
if (!await isEngineInstalled()) return false;
|
||||
try {
|
||||
final rootfs = await getRootfsDir();
|
||||
final repairCmd =
|
||||
'${ToolchainService.dpkgAutoHealPrefix} '
|
||||
'apt-get update && '
|
||||
'apt-get -f install -y 2>/dev/null || true;';
|
||||
|
||||
final res = await DistroManager().runHeadlessCommand(
|
||||
systemName: DistroRepository.defaultSystemName,
|
||||
customRootDir: rootfs,
|
||||
command: repairCmd,
|
||||
timeout: const Duration(minutes: 3),
|
||||
onStdout: onOutput,
|
||||
);
|
||||
return res != null && res.exitCode == 0;
|
||||
} catch (e) {
|
||||
debugPrint('修复 dpkg 状态异常: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 在 Ubuntu 系统中彻底卸载指定 apt 软件包及清理对应命令
|
||||
Future<bool> uninstallPackage(
|
||||
String packageName, {
|
||||
@@ -260,9 +284,8 @@ fi
|
||||
: '';
|
||||
|
||||
final uninstallCmd = '''
|
||||
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
|
||||
${ToolchainService.dpkgAutoHealPrefix}
|
||||
$killSection
|
||||
dpkg --configure -a 2>/dev/null || true
|
||||
apt-get remove --purge -y $targetsToPurge
|
||||
apt-get autoremove --purge -y
|
||||
$cmdCleanupSection
|
||||
|
||||
@@ -19,9 +19,9 @@ class ToolchainRequirement {
|
||||
required this.installCommand,
|
||||
});
|
||||
|
||||
/// 获取安装命令(带自动修复前缀)
|
||||
/// 获取安装命令(带自动修复与防死锁前缀)
|
||||
String get effectiveInstallCommand =>
|
||||
'DEBIAN_FRONTEND=noninteractive dpkg --configure -a 2>/dev/null || true; $installCommand';
|
||||
'${ToolchainService.dpkgAutoHealPrefix} $installCommand';
|
||||
|
||||
/// 兼容接口
|
||||
String? getInstallCommand([DistroFamily? family]) {
|
||||
@@ -32,8 +32,28 @@ class ToolchainRequirement {
|
||||
|
||||
/// 预编译软件源与工具链检测/安装适配服务(专为 Ubuntu 24.04 深度优化)
|
||||
class ToolchainService {
|
||||
/// 全局 Dpkg 自动修复与防死锁前置指令:
|
||||
/// 1. 设置非交互式环境变量,防止无终端卡死;
|
||||
/// 2. 清除残留的 lock 锁文件(防止异常中断遗留死锁);
|
||||
/// 3. 自动扫描并强制清理处于 reinstreq 或半安装 (half-installed/half-configured) 状态的损坏包,
|
||||
/// 防止其导致后续 dpkg --configure 及 apt-get 陷入死锁;
|
||||
/// 4. 自动执行 dpkg --configure -a 恢复环境。
|
||||
static const String dpkgAutoHealPrefix =
|
||||
'export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true; '
|
||||
'rm -f /var/lib/dpkg/lock* /var/lib/apt/lists/lock* /var/cache/apt/archives/lock* 2>/dev/null || true; '
|
||||
'for p in \$(dpkg-query -W -f=\'\${Package} \${Status}\\n\' 2>/dev/null | grep -E \'reinstreq|half-\' | cut -d\' \' -f1); do '
|
||||
' rm -f /var/lib/dpkg/info/\$p.* 2>/dev/null || true; '
|
||||
' dpkg --remove --force-all --force-remove-reinstreq "\$p" 2>/dev/null || true; '
|
||||
'done; '
|
||||
'dpkg --configure -a 2>/dev/null || true;';
|
||||
|
||||
/// 已注册的常用编译器与开发工具链元数据
|
||||
static const Map<String, ToolchainRequirement> supportedTools = {
|
||||
'git': ToolchainRequirement(
|
||||
checkBinary: 'git',
|
||||
displayName: 'Git 版本控制工具',
|
||||
installCommand: 'DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git',
|
||||
),
|
||||
'make': ToolchainRequirement(
|
||||
checkBinary: 'make',
|
||||
displayName: 'make 编译构建工具',
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/git_model.dart';
|
||||
|
||||
/// VS Code 风格的 Git 状态装饰工具类
|
||||
class GitDecorationUtils {
|
||||
/// 获取状态对应的文字/圆点颜色(自适应暗黑与明亮主题)
|
||||
static Color getStatusColor(GitFileStatusType type, {required bool isDark}) {
|
||||
switch (type) {
|
||||
case GitFileStatusType.modified:
|
||||
// VS Code Modified 经典暖沙金/琥珀色
|
||||
return isDark ? const Color(0xFFE2C08D) : const Color(0xFFB58900);
|
||||
case GitFileStatusType.untracked:
|
||||
case GitFileStatusType.added:
|
||||
// VS Code Untracked / Added 浅草绿
|
||||
return isDark ? const Color(0xFF73C991) : const Color(0xFF2E7D32);
|
||||
case GitFileStatusType.deleted:
|
||||
// VS Code Deleted 砖红
|
||||
return isDark ? const Color(0xFFE06C75) : const Color(0xFFC62828);
|
||||
case GitFileStatusType.unmerged:
|
||||
// VS Code Merge Conflict 醒目亮红
|
||||
return isDark ? const Color(0xFFFF5370) : const Color(0xFFD32F2F);
|
||||
case GitFileStatusType.renamed:
|
||||
case GitFileStatusType.copied:
|
||||
// 青色
|
||||
return isDark ? const Color(0xFF56B6C2) : const Color(0xFF00838F);
|
||||
case GitFileStatusType.typeChange:
|
||||
return isDark ? const Color(0xFFE5C07B) : const Color(0xFF8A6D3B);
|
||||
case GitFileStatusType.ignored:
|
||||
return isDark ? const Color(0xFF7F848E) : const Color(0xFF9E9E9E);
|
||||
case GitFileStatusType.unknown:
|
||||
return isDark ? const Color(0xFFABB2BF) : const Color(0xFF616161);
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取文件在右侧显示的状态缩写字母(如 M, U, A, D, !)
|
||||
static String? getStatusLetter(GitFileStatusType type) {
|
||||
switch (type) {
|
||||
case GitFileStatusType.modified:
|
||||
return 'M';
|
||||
case GitFileStatusType.untracked:
|
||||
return 'U';
|
||||
case GitFileStatusType.added:
|
||||
return 'A';
|
||||
case GitFileStatusType.deleted:
|
||||
return 'D';
|
||||
case GitFileStatusType.unmerged:
|
||||
return '!';
|
||||
case GitFileStatusType.renamed:
|
||||
return 'R';
|
||||
case GitFileStatusType.copied:
|
||||
return 'C';
|
||||
case GitFileStatusType.typeChange:
|
||||
return 'T';
|
||||
case GitFileStatusType.ignored:
|
||||
case GitFileStatusType.unknown:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// 状态优先级(用于目录层级聚合:冲突 > 删除 > 修改 > 新增 > 未跟踪 > 其他)
|
||||
static int getPriority(GitFileStatusType type) {
|
||||
switch (type) {
|
||||
case GitFileStatusType.unmerged:
|
||||
return 50;
|
||||
case GitFileStatusType.deleted:
|
||||
return 40;
|
||||
case GitFileStatusType.modified:
|
||||
return 30;
|
||||
case GitFileStatusType.added:
|
||||
return 20;
|
||||
case GitFileStatusType.untracked:
|
||||
return 15;
|
||||
case GitFileStatusType.renamed:
|
||||
case GitFileStatusType.copied:
|
||||
case GitFileStatusType.typeChange:
|
||||
return 10;
|
||||
case GitFileStatusType.ignored:
|
||||
return 5;
|
||||
case GitFileStatusType.unknown:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math' as math;
|
||||
|
||||
/// 差异行类型
|
||||
enum DiffLineType {
|
||||
/// 未更改
|
||||
unchanged,
|
||||
|
||||
/// 新增
|
||||
added,
|
||||
|
||||
/// 删除
|
||||
deleted,
|
||||
|
||||
/// 空占位行 (在双屏对齐模式下用于填充高度保持两侧对齐)
|
||||
empty,
|
||||
}
|
||||
|
||||
/// 单侧差异行模型
|
||||
class DiffLine {
|
||||
final DiffLineType type;
|
||||
final String text;
|
||||
final int? lineNumber;
|
||||
|
||||
const DiffLine({
|
||||
required this.type,
|
||||
required this.text,
|
||||
this.lineNumber,
|
||||
});
|
||||
|
||||
bool get isEmptyPlaceholder => type == DiffLineType.empty;
|
||||
}
|
||||
|
||||
/// 单屏内联差异行模型
|
||||
class UnifiedDiffLine {
|
||||
final DiffLineType type;
|
||||
final String text;
|
||||
final int? oldLineNumber;
|
||||
final int? newLineNumber;
|
||||
|
||||
const UnifiedDiffLine({
|
||||
required this.type,
|
||||
required this.text,
|
||||
this.oldLineNumber,
|
||||
this.newLineNumber,
|
||||
});
|
||||
}
|
||||
|
||||
/// 双屏差异对比计算结果
|
||||
class SplitDiffResult {
|
||||
final List<DiffLine> leftLines;
|
||||
final List<DiffLine> rightLines;
|
||||
final List<int> changeRowIndices;
|
||||
final int additionsCount;
|
||||
final int deletionsCount;
|
||||
|
||||
const SplitDiffResult({
|
||||
required this.leftLines,
|
||||
required this.rightLines,
|
||||
required this.changeRowIndices,
|
||||
required this.additionsCount,
|
||||
required this.deletionsCount,
|
||||
});
|
||||
}
|
||||
|
||||
/// Git Diff 算法与行对齐计算工具类
|
||||
class GitDiffHelper {
|
||||
/// 计算双屏并排对齐结果
|
||||
static SplitDiffResult computeSplitDiff(String originalText, String modifiedText) {
|
||||
final originalLines = _splitLines(originalText);
|
||||
final modifiedLines = _splitLines(modifiedText);
|
||||
|
||||
// 1. 公共前后缀快速收缩剪枝 (大幅提升常见文件差异计算性能)
|
||||
int prefixCount = 0;
|
||||
while (prefixCount < originalLines.length &&
|
||||
prefixCount < modifiedLines.length &&
|
||||
originalLines[prefixCount] == modifiedLines[prefixCount]) {
|
||||
prefixCount++;
|
||||
}
|
||||
|
||||
int suffixCount = 0;
|
||||
while (suffixCount < (originalLines.length - prefixCount) &&
|
||||
suffixCount < (modifiedLines.length - prefixCount) &&
|
||||
originalLines[originalLines.length - 1 - suffixCount] ==
|
||||
modifiedLines[modifiedLines.length - 1 - suffixCount]) {
|
||||
suffixCount++;
|
||||
}
|
||||
|
||||
final leftResult = <DiffLine>[];
|
||||
final rightResult = <DiffLine>[];
|
||||
final changeRowIndices = <int>[];
|
||||
int additions = 0;
|
||||
int deletions = 0;
|
||||
|
||||
// 前缀相同部分
|
||||
for (int i = 0; i < prefixCount; i++) {
|
||||
final line = originalLines[i];
|
||||
leftResult.add(DiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: line,
|
||||
lineNumber: i + 1,
|
||||
));
|
||||
rightResult.add(DiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: line,
|
||||
lineNumber: i + 1,
|
||||
));
|
||||
}
|
||||
|
||||
// 中间变化部分
|
||||
final middleOrig = originalLines.sublist(
|
||||
prefixCount,
|
||||
originalLines.length - suffixCount,
|
||||
);
|
||||
final middleMod = modifiedLines.sublist(
|
||||
prefixCount,
|
||||
modifiedLines.length - suffixCount,
|
||||
);
|
||||
|
||||
int origLineNo = prefixCount + 1;
|
||||
int modLineNo = prefixCount + 1;
|
||||
|
||||
final diffOps = _computeDiffOperations(middleOrig, middleMod);
|
||||
|
||||
// 将 diff 操作块分组合并以构建双屏对齐
|
||||
int opIndex = 0;
|
||||
while (opIndex < diffOps.length) {
|
||||
final op = diffOps[opIndex];
|
||||
|
||||
if (op.type == _DiffOpType.equal) {
|
||||
leftResult.add(DiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: op.text,
|
||||
lineNumber: origLineNo++,
|
||||
));
|
||||
rightResult.add(DiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: op.text,
|
||||
lineNumber: modLineNo++,
|
||||
));
|
||||
opIndex++;
|
||||
} else {
|
||||
// 遇到变更块 (连续的 delete 与 insert)
|
||||
final delBlock = <String>[];
|
||||
final addBlock = <String>[];
|
||||
|
||||
while (opIndex < diffOps.length && diffOps[opIndex].type != _DiffOpType.equal) {
|
||||
if (diffOps[opIndex].type == _DiffOpType.delete) {
|
||||
delBlock.add(diffOps[opIndex].text);
|
||||
deletions++;
|
||||
} else if (diffOps[opIndex].type == _DiffOpType.insert) {
|
||||
addBlock.add(diffOps[opIndex].text);
|
||||
additions++;
|
||||
}
|
||||
opIndex++;
|
||||
}
|
||||
|
||||
// 记录差异起点行索引
|
||||
changeRowIndices.add(leftResult.length);
|
||||
|
||||
final maxLen = math.max(delBlock.length, addBlock.length);
|
||||
for (int i = 0; i < maxLen; i++) {
|
||||
if (i < delBlock.length) {
|
||||
leftResult.add(DiffLine(
|
||||
type: DiffLineType.deleted,
|
||||
text: delBlock[i],
|
||||
lineNumber: origLineNo++,
|
||||
));
|
||||
} else {
|
||||
leftResult.add(const DiffLine(
|
||||
type: DiffLineType.empty,
|
||||
text: '',
|
||||
lineNumber: null,
|
||||
));
|
||||
}
|
||||
|
||||
if (i < addBlock.length) {
|
||||
rightResult.add(DiffLine(
|
||||
type: DiffLineType.added,
|
||||
text: addBlock[i],
|
||||
lineNumber: modLineNo++,
|
||||
));
|
||||
} else {
|
||||
rightResult.add(const DiffLine(
|
||||
type: DiffLineType.empty,
|
||||
text: '',
|
||||
lineNumber: null,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 后缀相同部分
|
||||
final origSuffixStart = originalLines.length - suffixCount;
|
||||
final modSuffixStart = modifiedLines.length - suffixCount;
|
||||
for (int i = 0; i < suffixCount; i++) {
|
||||
final line = originalLines[origSuffixStart + i];
|
||||
leftResult.add(DiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: line,
|
||||
lineNumber: origSuffixStart + i + 1,
|
||||
));
|
||||
rightResult.add(DiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: line,
|
||||
lineNumber: modSuffixStart + i + 1,
|
||||
));
|
||||
}
|
||||
|
||||
return SplitDiffResult(
|
||||
leftLines: leftResult,
|
||||
rightLines: rightResult,
|
||||
changeRowIndices: changeRowIndices,
|
||||
additionsCount: additions,
|
||||
deletionsCount: deletions,
|
||||
);
|
||||
}
|
||||
|
||||
/// 将双屏结果或文本转换为单屏内联 (Unified) 差异行列表
|
||||
static List<UnifiedDiffLine> toUnifiedDiff(String originalText, String modifiedText) {
|
||||
final originalLines = _splitLines(originalText);
|
||||
final modifiedLines = _splitLines(modifiedText);
|
||||
|
||||
final diffOps = _computeDiffOperations(originalLines, modifiedLines);
|
||||
final result = <UnifiedDiffLine>[];
|
||||
|
||||
int origLineNo = 1;
|
||||
int modLineNo = 1;
|
||||
|
||||
for (final op in diffOps) {
|
||||
switch (op.type) {
|
||||
case _DiffOpType.equal:
|
||||
result.add(UnifiedDiffLine(
|
||||
type: DiffLineType.unchanged,
|
||||
text: op.text,
|
||||
oldLineNumber: origLineNo++,
|
||||
newLineNumber: modLineNo++,
|
||||
));
|
||||
break;
|
||||
case _DiffOpType.delete:
|
||||
result.add(UnifiedDiffLine(
|
||||
type: DiffLineType.deleted,
|
||||
text: op.text,
|
||||
oldLineNumber: origLineNo++,
|
||||
newLineNumber: null,
|
||||
));
|
||||
break;
|
||||
case _DiffOpType.insert:
|
||||
result.add(UnifiedDiffLine(
|
||||
type: DiffLineType.added,
|
||||
text: op.text,
|
||||
oldLineNumber: null,
|
||||
newLineNumber: modLineNo++,
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static List<String> _splitLines(String text) {
|
||||
if (text.isEmpty) return [];
|
||||
return const LineSplitter().convert(text);
|
||||
}
|
||||
|
||||
/// 计算差异编辑脚本 (基于标准动态规划 LCS 矩阵,针对超长文本具备平滑防御)
|
||||
static List<_DiffOp> _computeDiffOperations(List<String> a, List<String> b) {
|
||||
final n = a.length;
|
||||
final m = b.length;
|
||||
|
||||
if (n == 0) {
|
||||
return b.map((text) => _DiffOp(_DiffOpType.insert, text)).toList();
|
||||
}
|
||||
if (m == 0) {
|
||||
return a.map((text) => _DiffOp(_DiffOpType.delete, text)).toList();
|
||||
}
|
||||
|
||||
// 防御过大矩阵导致的 OOM (单次差异超过 200,000 元素积时快速回退)
|
||||
if (n * m > 250000) {
|
||||
return [
|
||||
...a.map((text) => _DiffOp(_DiffOpType.delete, text)),
|
||||
...b.map((text) => _DiffOp(_DiffOpType.insert, text)),
|
||||
];
|
||||
}
|
||||
|
||||
// LCS 动态规划
|
||||
final dp = List.generate(n + 1, (_) => List<int>.filled(m + 1, 0));
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (a[i] == b[j]) {
|
||||
dp[i + 1][j + 1] = dp[i][j] + 1;
|
||||
} else {
|
||||
dp[i + 1][j + 1] = math.max(dp[i + 1][j], dp[i][j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 回溯生成操作队列
|
||||
final ops = <_DiffOp>[];
|
||||
int i = n;
|
||||
int j = m;
|
||||
|
||||
while (i > 0 || j > 0) {
|
||||
if (i > 0 && j > 0 && a[i - 1] == b[j - 1]) {
|
||||
ops.add(_DiffOp(_DiffOpType.equal, a[i - 1]));
|
||||
i--;
|
||||
j--;
|
||||
} else if (j > 0 && (i == 0 || dp[i][j - 1] >= dp[i - 1][j])) {
|
||||
ops.add(_DiffOp(_DiffOpType.insert, b[j - 1]));
|
||||
j--;
|
||||
} else if (i > 0 && (j == 0 || dp[i][j - 1] < dp[i - 1][j])) {
|
||||
ops.add(_DiffOp(_DiffOpType.delete, a[i - 1]));
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
return ops.reversed.toList();
|
||||
}
|
||||
}
|
||||
|
||||
enum _DiffOpType { equal, delete, insert }
|
||||
|
||||
class _DiffOp {
|
||||
final _DiffOpType type;
|
||||
final String text;
|
||||
|
||||
_DiffOp(this.type, this.text);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:re_editor/re_editor.dart';
|
||||
import 'package:re_highlight/languages/all.dart';
|
||||
@@ -183,4 +184,31 @@ class SyntaxHighlightHelper {
|
||||
if (langId == null) return null;
|
||||
return builtinAllLanguages[langId];
|
||||
}
|
||||
|
||||
static final Highlight _highlightInstance = Highlight()..registerLanguages(builtinAllLanguages);
|
||||
|
||||
/// 针对单行代码生成带语法高亮的 TextSpan(供 Diff 视图等只读代码渲染)
|
||||
static TextSpan highlightLine({
|
||||
required String code,
|
||||
required String? filePath,
|
||||
required TextStyle baseStyle,
|
||||
required Map<String, TextStyle> highlightTheme,
|
||||
}) {
|
||||
if (code.isEmpty) {
|
||||
return TextSpan(text: '', style: baseStyle);
|
||||
}
|
||||
final langId = getLanguageId(filePath);
|
||||
if (langId == null) {
|
||||
return TextSpan(text: code, style: baseStyle);
|
||||
}
|
||||
try {
|
||||
final result = _highlightInstance.highlight(code: code, language: langId);
|
||||
final renderer = TextSpanRenderer(baseStyle, highlightTheme);
|
||||
result.render(renderer);
|
||||
return renderer.span ?? TextSpan(text: code, style: baseStyle);
|
||||
} catch (_) {
|
||||
return TextSpan(text: code, style: baseStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/providers/distro_provider.dart';
|
||||
import 'package:code_editor/providers/git_provider.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/providers/run_provider.dart';
|
||||
import 'package:code_editor/providers/tab_provider.dart';
|
||||
@@ -9,6 +10,7 @@ import 'package:code_editor/utils/dialog_utils.dart';
|
||||
import 'package:code_editor/views/project_management_view.dart';
|
||||
import 'package:code_editor/widgets/project_history_widget.dart';
|
||||
import 'package:code_editor/widgets/file_tree_widget.dart';
|
||||
import 'package:code_editor/widgets/git/git_panel_widget.dart';
|
||||
import 'package:code_editor/widgets/search/search_panel_widget.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -142,6 +144,7 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
required int index,
|
||||
required IconData icon,
|
||||
required String label,
|
||||
int? badgeCount,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
final isSelected = _selectedIndex == index;
|
||||
@@ -188,6 +191,36 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
? colorScheme.primary
|
||||
: colorScheme.onSurfaceVariant.withValues(alpha: 0.7),
|
||||
),
|
||||
if (badgeCount != null && badgeCount > 0)
|
||||
Positioned(
|
||||
right: 4,
|
||||
bottom: 5,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 16,
|
||||
minHeight: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.surfaceContainerLow,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
badgeCount > 99 ? '99+' : badgeCount.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onPrimary,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -200,6 +233,9 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
final gitProvider = context.watch<GitProvider?>();
|
||||
final gitBadgeCount = (gitProvider?.isGitRepo ?? false) ? (gitProvider?.totalChangedCount ?? 0) : 0;
|
||||
|
||||
return Container(
|
||||
width: 48,
|
||||
decoration: BoxDecoration(
|
||||
@@ -236,6 +272,7 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
index: 2,
|
||||
icon: Icons.alt_route_rounded,
|
||||
label: l10n.drawerTabGit,
|
||||
badgeCount: gitBadgeCount,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -449,45 +486,6 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
|
||||
|
||||
|
||||
Widget _buildGitPlaceholder(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primaryContainer,
|
||||
),
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
left: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 14.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.drawerTabGit,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -502,12 +500,12 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
children: [
|
||||
_buildActivityBar(context, l10n, theme),
|
||||
Expanded(
|
||||
child: IndexedStack(
|
||||
child: _LazyIndexedStack(
|
||||
index: _selectedIndex,
|
||||
children: [
|
||||
_buildExplorerPage(context, l10n, theme, rootPath, hasProject),
|
||||
const SearchPanelWidget(),
|
||||
_buildGitPlaceholder(context, l10n, theme),
|
||||
builders: [
|
||||
(ctx) => _buildExplorerPage(ctx, l10n, theme, rootPath, hasProject),
|
||||
(ctx) => const SearchPanelWidget(),
|
||||
(ctx) => const GitPanelWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -516,3 +514,53 @@ class _CodeEditorDrawerState extends State<CodeEditorDrawer> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 惰性按需挂载的 IndexedStack,仅在 Tab 首次被激活时实例化子 Widget,
|
||||
/// 并通过 Offstage + TickerMode 永久保持状态与滚动偏移,杜绝抽屉初次滑出时全量构建卡顿。
|
||||
class _LazyIndexedStack extends StatefulWidget {
|
||||
final int index;
|
||||
final List<WidgetBuilder> builders;
|
||||
|
||||
const _LazyIndexedStack({
|
||||
required this.index,
|
||||
required this.builders,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_LazyIndexedStack> createState() => _LazyIndexedStackState();
|
||||
}
|
||||
|
||||
class _LazyIndexedStackState extends State<_LazyIndexedStack> {
|
||||
late final Set<int> _activatedIndices;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_activatedIndices = {widget.index};
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant _LazyIndexedStack oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
_activatedIndices.add(widget.index);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: List.generate(widget.builders.length, (i) {
|
||||
final isActivated = _activatedIndices.contains(i);
|
||||
final isSelected = widget.index == i;
|
||||
|
||||
return Offstage(
|
||||
offstage: !isSelected,
|
||||
child: TickerMode(
|
||||
enabled: isSelected,
|
||||
child: isActivated ? widget.builders[i](context) : const SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -501,32 +501,13 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
|
||||
curOpt.pattern != query ||
|
||||
curOpt.caseSensitive != searchProvider.caseSensitive ||
|
||||
curOpt.regex != searchProvider.isRegex) {
|
||||
if (query.isEmpty) {
|
||||
if (curVal != null && curOpt?.pattern.isNotEmpty == true) {
|
||||
// 注意:不能直接调用 _findController!.close(),
|
||||
// 因为 re_editor 内部在 value == null 时会强制执行 widget.focusNode.requestFocus(),
|
||||
// 导致侧边抽屉中的搜索输入框在内容清空时瞬间失去焦点。
|
||||
// 此处同时临时锁定 _focusNode.canRequestFocus 并赋空匹配正则,彻底杜绝编辑器抢夺焦点。
|
||||
final wasCanRequest = _focusNode.canRequestFocus;
|
||||
_focusNode.canRequestFocus = false;
|
||||
try {
|
||||
_findController!.value = const CodeFindValue(
|
||||
option: CodeFindOption(
|
||||
pattern: r'(?!)',
|
||||
caseSensitive: false,
|
||||
regex: true,
|
||||
),
|
||||
replaceMode: false,
|
||||
searching: false,
|
||||
);
|
||||
} finally {
|
||||
_focusNode.canRequestFocus = wasCanRequest;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final wasCanRequest = _focusNode.canRequestFocus;
|
||||
_focusNode.canRequestFocus = false;
|
||||
try {
|
||||
// 严禁设置 _focusNode.canRequestFocus = false!
|
||||
// 在 Flutter 框架中,当编辑区拥有焦点时(用户正在编辑代码输入),
|
||||
// 将 canRequestFocus 置为 false 会强制触发 unfocus(),紧接着在输入时又重获焦点,
|
||||
// 造成软键盘反复弹起收起(一跳一跳的致命抖动)。
|
||||
// 同时此处保持 _findController.value 非 null(pattern 为 query),
|
||||
// re_editor 在 pattern 为空时会自动将 matches 清空,既彻底清除了高亮,
|
||||
// 又避免了在 value == null 时触发 re_editor 内部偷夺焦点的 requestFocus()。
|
||||
_findController!.value = CodeFindValue(
|
||||
option: CodeFindOption(
|
||||
pattern: query,
|
||||
@@ -534,15 +515,11 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
|
||||
regex: searchProvider.isRegex,
|
||||
),
|
||||
replaceMode: false,
|
||||
searching: true,
|
||||
searching: query.isNotEmpty,
|
||||
);
|
||||
if (_findController!.findInputController.text != query) {
|
||||
_findController!.findInputController.text = query;
|
||||
}
|
||||
} finally {
|
||||
_focusNode.canRequestFocus = wasCanRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,7 +775,11 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
|
||||
} catch (_) {}
|
||||
|
||||
final searchProvider = context.watch<SearchProvider?>();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
_syncSearchHighlight(searchProvider);
|
||||
}
|
||||
});
|
||||
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final hasNoProject = widget.rootPath == null || widget.rootPath!.trim().isEmpty;
|
||||
@@ -1130,7 +1111,18 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
|
||||
|
||||
_controller = newController;
|
||||
_findController?.dispose();
|
||||
_findController = CodeFindController(newController);
|
||||
_findController = CodeFindController(
|
||||
newController,
|
||||
const CodeFindValue(
|
||||
option: CodeFindOption(
|
||||
pattern: '',
|
||||
caseSensitive: false,
|
||||
regex: false,
|
||||
),
|
||||
replaceMode: false,
|
||||
searching: false,
|
||||
),
|
||||
);
|
||||
_currentLoadedPath = fullFilePath;
|
||||
_currentIndentSize = activeIndentSize;
|
||||
_errorMessage = null;
|
||||
@@ -1196,7 +1188,18 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
|
||||
|
||||
_controller = newController;
|
||||
_findController?.dispose();
|
||||
_findController = CodeFindController(newController);
|
||||
_findController = CodeFindController(
|
||||
newController,
|
||||
const CodeFindValue(
|
||||
option: CodeFindOption(
|
||||
pattern: '',
|
||||
caseSensitive: false,
|
||||
regex: false,
|
||||
),
|
||||
replaceMode: false,
|
||||
searching: false,
|
||||
),
|
||||
);
|
||||
_currentLoadedPath = fullFilePath;
|
||||
_currentIndentSize = activeIndentSize;
|
||||
_errorMessage = null;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/models/file_item.dart';
|
||||
import 'package:code_editor/providers/git_provider.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/providers/tab_provider.dart';
|
||||
import 'package:code_editor/services/permission_service.dart';
|
||||
import 'package:code_editor/utils/dialog_utils.dart';
|
||||
import 'package:code_editor/utils/file_icon_utils.dart';
|
||||
import 'package:code_editor/utils/git_decoration_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -30,6 +32,14 @@ class _FileItemWidgetState extends State<FileItemWidget> {
|
||||
return listen ? context.watch<TabProvider>() : context.read<TabProvider>();
|
||||
}
|
||||
|
||||
static GitProvider? _getGitProvider(BuildContext context, {bool listen = false}) {
|
||||
try {
|
||||
return listen ? context.watch<GitProvider>() : context.read<GitProvider>();
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _buildFileItem(context, widget.fileItem);
|
||||
@@ -39,22 +49,41 @@ class _FileItemWidgetState extends State<FileItemWidget> {
|
||||
final theme = Theme.of(context);
|
||||
final projectProvider = _getProjectProvider(context, listen: true);
|
||||
final tabProvider = _getTabProvider(context, listen: true);
|
||||
final gitProvider = _getGitProvider(context, listen: true);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
final indent = EdgeInsets.only(left: item.depth * 16.0 + 8.0, right: 8.0);
|
||||
|
||||
// 获取 Git 状态修饰
|
||||
final gitFileStatus = !item.isDirectory && gitProvider != null
|
||||
? gitProvider.getFileStatus(item.path)
|
||||
: null;
|
||||
final gitDirStatusType = item.isDirectory && gitProvider != null
|
||||
? gitProvider.getDirectoryStatus(item.path)
|
||||
: null;
|
||||
|
||||
final Color? gitColor = !item.isDirectory
|
||||
? (gitFileStatus != null
|
||||
? GitDecorationUtils.getStatusColor(gitFileStatus.statusType, isDark: isDark)
|
||||
: null)
|
||||
: (gitDirStatusType != null
|
||||
? GitDecorationUtils.getStatusColor(gitDirStatusType, isDark: isDark)
|
||||
: null);
|
||||
|
||||
// 判断该文件是否处于被剪切状态
|
||||
final isCut = projectProvider.isItemCut(item.path);
|
||||
|
||||
// 判断该文件是否为当前正在编辑/修改的文件
|
||||
final isSelected = !item.isDirectory && tabProvider.isFileSelected(item.path);
|
||||
|
||||
// 文字样式:剪切时变灰,选中时高亮,其余正常
|
||||
// 文字样式:剪切时变灰,选中时高亮,有 Git 状态时使用 Git 状态色,其余正常
|
||||
final itemTextStyle = theme.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: isCut
|
||||
? theme.colorScheme.onSurface.withValues(alpha: 0.38)
|
||||
: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: null,
|
||||
: gitColor,
|
||||
);
|
||||
|
||||
final iconColor = isCut
|
||||
@@ -64,36 +93,95 @@ class _FileItemWidgetState extends State<FileItemWidget> {
|
||||
: null;
|
||||
|
||||
if (item.isDirectory) {
|
||||
Widget? dirTrailing;
|
||||
if (gitColor != null && gitDirStatusType != null) {
|
||||
dirTrailing = SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 7,
|
||||
height: 7,
|
||||
decoration: BoxDecoration(
|
||||
color: gitColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onLongPressStart: (details) {
|
||||
_showContextMenu(item, details.globalPosition);
|
||||
},
|
||||
child: ExpansionTile(
|
||||
key: PageStorageKey(item.path),
|
||||
initiallyExpanded: item.isOpen,
|
||||
tilePadding: indent,
|
||||
leading: Icon(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 1.0),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: ListTile(
|
||||
contentPadding: indent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
dense: true,
|
||||
leading: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
item.isOpen ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
||||
size: 16,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
item.isOpen ? Icons.folder_open_outlined : Icons.folder_outlined,
|
||||
color: isCut ? iconColor : null,
|
||||
color: isCut ? iconColor : (item.isOpen ? theme.colorScheme.primary : null),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Text(
|
||||
item.name,
|
||||
style: itemTextStyle,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
dense: true,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
trailing: dirTrailing,
|
||||
onTap: () {
|
||||
final newExpanded = !item.isOpen;
|
||||
setState(() {
|
||||
item.isOpen = expanded;
|
||||
item.isOpen = newExpanded;
|
||||
});
|
||||
_getProjectProvider(context).toggleDirectory(item, expanded);
|
||||
_getProjectProvider(context).toggleDirectory(item, newExpanded);
|
||||
},
|
||||
children: item.children
|
||||
.map((child) => FileItemWidget(fileItem: child))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Widget? fileTrailing;
|
||||
if (gitColor != null && gitFileStatus != null) {
|
||||
final letter = GitDecorationUtils.getStatusLetter(gitFileStatus.statusType);
|
||||
if (letter != null && letter.isNotEmpty) {
|
||||
fileTrailing = SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: Center(
|
||||
child: Text(
|
||||
letter,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: gitColor,
|
||||
height: 1.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onLongPressStart: (details) {
|
||||
_showContextMenu(item, details.globalPosition);
|
||||
@@ -117,7 +205,10 @@ class _FileItemWidgetState extends State<FileItemWidget> {
|
||||
title: Text(
|
||||
item.name,
|
||||
style: itemTextStyle,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: fileTrailing,
|
||||
dense: true,
|
||||
onTap: () {
|
||||
final scaffold = Scaffold.maybeOf(context);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/models/file_item.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/widgets/file_item_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -53,13 +54,27 @@ class FileTreeWidget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// 3. 动态扁平化已展开的目录树,使所有深度的文件节点均能通过 ListView.builder 获得真正的行级虚拟化
|
||||
final flatItems = <FileItem>[];
|
||||
void flatten(List<FileItem> list) {
|
||||
for (final it in list) {
|
||||
flatItems.add(it);
|
||||
if (it.isDirectory && it.isOpen && it.children.isNotEmpty) {
|
||||
flatten(it.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
flatten(items);
|
||||
|
||||
return ListView.builder(
|
||||
key: const PageStorageKey('code_editor_file_tree_list'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
itemCount: items.length,
|
||||
itemCount: flatItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = flatItems[index];
|
||||
return FileItemWidget(
|
||||
fileItem: items[index],
|
||||
key: ValueKey(item.path),
|
||||
fileItem: item,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,110 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../models/git_model.dart';
|
||||
|
||||
/// VS Code 风格 Git 提交历史拓扑图绘制器
|
||||
class GitGraphPainter extends CustomPainter {
|
||||
final GitCommit commit;
|
||||
final bool isFirstCommit;
|
||||
final ColorScheme colorScheme;
|
||||
|
||||
static const double laneWidth = 14.0;
|
||||
static const double startOffset = 14.0;
|
||||
|
||||
// 经典多分支着色调色板
|
||||
static const List<Color> laneColors = [
|
||||
Color(0xFF2196F3), // 蓝
|
||||
Color(0xFF4CAF50), // 绿
|
||||
Color(0xFFFF9800), // 橙
|
||||
Color(0xFFE91E63), // 粉红
|
||||
Color(0xFF9C27B0), // 紫
|
||||
Color(0xFF00BCD4), // 青
|
||||
Color(0xFFFFEB3B), // 黄
|
||||
Color(0xFF795548), // 棕
|
||||
];
|
||||
|
||||
static Color getLaneColor(int lane) {
|
||||
return laneColors[lane % laneColors.length];
|
||||
}
|
||||
|
||||
const GitGraphPainter({
|
||||
required this.commit,
|
||||
required this.isFirstCommit,
|
||||
required this.colorScheme,
|
||||
});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final centerY = size.height / 2;
|
||||
final nodeX = startOffset + commit.lane * laneWidth;
|
||||
final nodeColor = getLaneColor(commit.lane);
|
||||
|
||||
final linePaint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2.0
|
||||
..strokeCap = StrokeCap.round;
|
||||
|
||||
// 1. 绘制穿透此行的其他活跃通道
|
||||
for (final lane in commit.activeLanes) {
|
||||
if (lane == commit.lane) continue;
|
||||
final x = startOffset + lane * laneWidth;
|
||||
linePaint.color = getLaneColor(lane);
|
||||
canvas.drawLine(Offset(x, 0), Offset(x, size.height), linePaint);
|
||||
}
|
||||
|
||||
// 2. 绘制进入当前节点的连线(如果不是首个展示的提交,说明上方有子提交连入)
|
||||
if (!isFirstCommit) {
|
||||
linePaint.color = nodeColor;
|
||||
canvas.drawLine(Offset(nodeX, 0), Offset(nodeX, centerY), linePaint);
|
||||
}
|
||||
|
||||
// 3. 绘制当前节点连向父提交的连线
|
||||
for (final targetLane in commit.outgoingLanes) {
|
||||
final targetX = startOffset + targetLane * laneWidth;
|
||||
linePaint.color = nodeColor;
|
||||
|
||||
if (targetLane == commit.lane) {
|
||||
// 直线向下连到下一行
|
||||
canvas.drawLine(Offset(nodeX, centerY), Offset(nodeX, size.height), linePaint);
|
||||
} else {
|
||||
// 跨分支弧线(贝塞尔平滑曲线)
|
||||
final path = Path();
|
||||
path.moveTo(nodeX, centerY);
|
||||
final controlY = centerY + (size.height - centerY) * 0.5;
|
||||
path.cubicTo(nodeX, controlY, targetX, controlY, targetX, size.height);
|
||||
canvas.drawPath(path, linePaint);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 绘制提交节点
|
||||
final bgPaint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = colorScheme.surface;
|
||||
|
||||
final dotPaint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = nodeColor;
|
||||
|
||||
// 节点外围背景微隔离圈,防止与连线黏连
|
||||
canvas.drawCircle(Offset(nodeX, centerY), 6.5, bgPaint);
|
||||
|
||||
if (commit.isHead) {
|
||||
// HEAD 节点:外圈光环 + 内部实心
|
||||
final haloPaint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2.2
|
||||
..color = nodeColor;
|
||||
canvas.drawCircle(Offset(nodeX, centerY), 6.0, haloPaint);
|
||||
canvas.drawCircle(Offset(nodeX, centerY), 3.2, dotPaint);
|
||||
} else {
|
||||
// 普通节点:实心圆
|
||||
canvas.drawCircle(Offset(nodeX, centerY), 4.5, dotPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant GitGraphPainter oldDelegate) {
|
||||
return oldDelegate.commit != commit ||
|
||||
oldDelegate.isFirstCommit != isFirstCommit ||
|
||||
oldDelegate.colorScheme != colorScheme;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -459,6 +459,15 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
if (options.mode == SearchMode.fileName && result.fileResults.isNotEmpty) ...[
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
iconSize: 18,
|
||||
tooltip: l10n.expandAll,
|
||||
icon: const Icon(Icons.unfold_more),
|
||||
onPressed: () => searchProvider.loadAllFiles(),
|
||||
),
|
||||
],
|
||||
if (options.mode == SearchMode.text && result.fileResults.isNotEmpty) ...[
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
@@ -781,6 +790,44 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
final visibleFiles = allFiles.take(visibleFilesCount).toList();
|
||||
final hasMoreFiles = allFiles.length > visibleFilesCount;
|
||||
final remainingFilesCount = allFiles.length - visibleFilesCount;
|
||||
final isFileNameMode = options.mode == SearchMode.fileName;
|
||||
|
||||
// 将搜索树状结构扁平化为一维条目列表,供单一 ListView.builder 进行真正的行级虚拟化
|
||||
final List<_SearchRowItem> flattenedItems = [];
|
||||
if (isFileNameMode) {
|
||||
for (final file in visibleFiles) {
|
||||
flattenedItems.add(_SearchFileNameRowItem(file));
|
||||
}
|
||||
} else {
|
||||
for (final file in visibleFiles) {
|
||||
flattenedItems.add(_SearchFileHeaderRowItem(file));
|
||||
if (file.isExpanded) {
|
||||
final currentMatchesLimit = searchProvider.getFileMatchesLimit(
|
||||
file.filePath,
|
||||
SearchPanelWidget.defaultFileMatchesPageSize,
|
||||
);
|
||||
final allMatches = file.matches;
|
||||
final visibleMatchesCount = allMatches.length < currentMatchesLimit
|
||||
? allMatches.length
|
||||
: currentMatchesLimit;
|
||||
for (var i = 0; i < visibleMatchesCount; i++) {
|
||||
flattenedItems.add(_SearchMatchLineRowItem(file, allMatches[i]));
|
||||
}
|
||||
if (allMatches.length > visibleMatchesCount) {
|
||||
flattenedItems.add(
|
||||
_SearchLoadMoreMatchesRowItem(
|
||||
file,
|
||||
allMatches.length - visibleMatchesCount,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMoreFiles) {
|
||||
flattenedItems.add(_SearchLoadMoreFilesRowItem(remainingFilesCount));
|
||||
}
|
||||
|
||||
return MediaQuery.removePadding(
|
||||
context: context,
|
||||
@@ -789,48 +836,120 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
key: const PageStorageKey('project_search_results_list'),
|
||||
controller: _scrollController,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: visibleFiles.length + (hasMoreFiles ? 1 : 0),
|
||||
itemBuilder: (context, fileIndex) {
|
||||
if (fileIndex == visibleFiles.length) {
|
||||
return _buildLoadMoreFilesTile(
|
||||
itemCount: flattenedItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = flattenedItems[index];
|
||||
return switch (item) {
|
||||
_SearchFileNameRowItem(:final file) => _buildFileNameTile(
|
||||
context,
|
||||
theme,
|
||||
file,
|
||||
tabProvider,
|
||||
),
|
||||
_SearchFileHeaderRowItem(:final file) => _buildFileHeaderTile(
|
||||
context,
|
||||
theme,
|
||||
l10n,
|
||||
file,
|
||||
searchProvider,
|
||||
tabProvider,
|
||||
options,
|
||||
),
|
||||
_SearchMatchLineRowItem(:final file, :final match) =>
|
||||
_buildMatchLineTile(
|
||||
context,
|
||||
theme,
|
||||
l10n,
|
||||
file,
|
||||
match,
|
||||
searchProvider,
|
||||
tabProvider,
|
||||
options,
|
||||
),
|
||||
_SearchLoadMoreMatchesRowItem(
|
||||
:final file,
|
||||
:final remainingMatchesCount
|
||||
) =>
|
||||
_buildLoadMoreMatchesTile(
|
||||
theme,
|
||||
l10n,
|
||||
file,
|
||||
remainingMatchesCount,
|
||||
searchProvider,
|
||||
),
|
||||
_SearchLoadMoreFilesRowItem(:final remainingFilesCount) =>
|
||||
_buildLoadMoreFilesTile(
|
||||
theme,
|
||||
l10n,
|
||||
remainingFilesCount,
|
||||
searchProvider,
|
||||
),
|
||||
};
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final fileResult = visibleFiles[fileIndex];
|
||||
final isExpanded = fileResult.isExpanded;
|
||||
final dirName = p.dirname(fileResult.relativePath);
|
||||
final hasDir = dirName != '.' && dirName.isNotEmpty;
|
||||
|
||||
final currentMatchesLimit = searchProvider.getFileMatchesLimit(
|
||||
fileResult.filePath,
|
||||
SearchPanelWidget.defaultFileMatchesPageSize,
|
||||
/// 加载更多文件条目
|
||||
Widget _buildLoadMoreFilesTile(
|
||||
ThemeData theme,
|
||||
AppLocalizations l10n,
|
||||
int remainingFilesCount,
|
||||
SearchProvider searchProvider,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
searchProvider.loadMoreFiles(SearchPanelWidget.defaultFilesPageSize);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.expand_more, size: 16, color: theme.colorScheme.primary),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
l10n.searchLoadMoreFiles(remainingFilesCount),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
final allMatches = fileResult.matches;
|
||||
final visibleMatchesCount = allMatches.length < currentMatchesLimit
|
||||
? allMatches.length
|
||||
: currentMatchesLimit;
|
||||
final visibleMatches = allMatches.take(visibleMatchesCount).toList();
|
||||
final hasMoreMatches = allMatches.length > visibleMatchesCount;
|
||||
final remainingMatchesCount = allMatches.length - visibleMatchesCount;
|
||||
}
|
||||
|
||||
final isFileNameMode = options.mode == SearchMode.fileName;
|
||||
|
||||
if (isFileNameMode) {
|
||||
// 文件名/文件夹名匹配模式:普通扁平 item,不折叠,高亮直接绘制在主标题文件名上
|
||||
/// 构建文件名/目录名匹配模式的单项条目
|
||||
Widget _buildFileNameTile(
|
||||
BuildContext context,
|
||||
ThemeData theme,
|
||||
FileSearchResult fileResult,
|
||||
TabProvider? tabProvider,
|
||||
) {
|
||||
final match = fileResult.matches.isNotEmpty ? fileResult.matches.first : null;
|
||||
final iconData = FileIconUtils.getIcon(
|
||||
name: fileResult.fileName,
|
||||
isDirectory: fileResult.isDirectory,
|
||||
);
|
||||
final dirName = p.dirname(fileResult.relativePath);
|
||||
final hasDir = dirName != '.' && dirName.isNotEmpty;
|
||||
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
if (fileResult.isDirectory) {
|
||||
// 点击文件夹搜索项:展开并跳转到目录
|
||||
final projectProvider = context.read<ProjectProvider?>();
|
||||
if (projectProvider != null) {
|
||||
final cleanRoot = projectProvider.rootPath;
|
||||
@@ -851,7 +970,6 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 点击文件搜索项:打开并进入编辑该文件
|
||||
if (tabProvider != null) {
|
||||
await tabProvider.openFile(fileResult.filePath);
|
||||
}
|
||||
@@ -880,7 +998,6 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 主标题:文件名带关键词高亮
|
||||
_buildFileNameHighlightedTitle(
|
||||
fileResult.fileName,
|
||||
match,
|
||||
@@ -908,17 +1025,25 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
// 文本内容匹配模式:可折叠树形结构展示
|
||||
/// 构建文本匹配模式下的文件分组头部条目
|
||||
Widget _buildFileHeaderTile(
|
||||
BuildContext context,
|
||||
ThemeData theme,
|
||||
AppLocalizations l10n,
|
||||
FileSearchResult fileResult,
|
||||
SearchProvider searchProvider,
|
||||
TabProvider? tabProvider,
|
||||
SearchOptions options,
|
||||
) {
|
||||
final isExpanded = fileResult.isExpanded;
|
||||
final dirName = p.dirname(fileResult.relativePath);
|
||||
final hasDir = dirName != '.' && dirName.isNotEmpty;
|
||||
final iconData = FileIconUtils.getIcon(
|
||||
name: fileResult.fileName,
|
||||
isDirectory: fileResult.isDirectory,
|
||||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 文件分组条目
|
||||
InkWell(
|
||||
return InkWell(
|
||||
onTap: () => searchProvider.toggleFileExpanded(fileResult),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
@@ -991,6 +1116,26 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
),
|
||||
),
|
||||
|
||||
// 该文件折叠项全部展开按钮:一键展开并展示该文件内所有匹配行
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
style: IconButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
minimumSize: Size.zero,
|
||||
padding: const EdgeInsets.all(4),
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 24,
|
||||
minHeight: 24,
|
||||
),
|
||||
iconSize: 16,
|
||||
icon: const Icon(Icons.unfold_more_rounded),
|
||||
tooltip: l10n.searchExpandAllMatchesInFile,
|
||||
onPressed: () {
|
||||
searchProvider.expandAndLoadAllMatchesForFile(fileResult);
|
||||
},
|
||||
),
|
||||
|
||||
// 文件级全部替换按钮:仅在展开替换输入框时展示
|
||||
if (options.mode == SearchMode.text && options.isReplaceExpanded)
|
||||
IconButton(
|
||||
@@ -1037,11 +1182,20 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 展开展示具体匹配行(按需分页加载)
|
||||
if (isExpanded) ...[
|
||||
...visibleMatches.map((match) {
|
||||
/// 构建具体代码匹配行条目
|
||||
Widget _buildMatchLineTile(
|
||||
BuildContext context,
|
||||
ThemeData theme,
|
||||
AppLocalizations l10n,
|
||||
FileSearchResult fileResult,
|
||||
LineMatch match,
|
||||
SearchProvider searchProvider,
|
||||
TabProvider? tabProvider,
|
||||
SearchOptions options,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
if (tabProvider != null) {
|
||||
@@ -1119,11 +1273,17 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
}
|
||||
|
||||
// 文件内更多匹配项加载按钮
|
||||
if (hasMoreMatches)
|
||||
InkWell(
|
||||
/// 构建文件内更多匹配项加载按钮条目
|
||||
Widget _buildLoadMoreMatchesTile(
|
||||
ThemeData theme,
|
||||
AppLocalizations l10n,
|
||||
FileSearchResult fileResult,
|
||||
int remainingMatchesCount,
|
||||
SearchProvider searchProvider,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
searchProvider.loadMoreMatches(
|
||||
fileResult.filePath,
|
||||
@@ -1156,54 +1316,41 @@ class _SearchPanelWidgetState extends State<SearchPanelWidget> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 加载更多文件条目
|
||||
Widget _buildLoadMoreFilesTile(
|
||||
ThemeData theme,
|
||||
AppLocalizations l10n,
|
||||
int remainingFilesCount,
|
||||
SearchProvider searchProvider,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
searchProvider.loadMoreFiles(SearchPanelWidget.defaultFilesPageSize);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.expand_more, size: 16, color: theme.colorScheme.primary),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
l10n.searchLoadMoreFiles(remainingFilesCount),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 扁平化虚拟条目抽象基类
|
||||
sealed class _SearchRowItem {}
|
||||
|
||||
/// 文件名检索模式条目
|
||||
class _SearchFileNameRowItem extends _SearchRowItem {
|
||||
final FileSearchResult file;
|
||||
_SearchFileNameRowItem(this.file);
|
||||
}
|
||||
|
||||
/// 文本内容检索模式下的文件分组头部条目
|
||||
class _SearchFileHeaderRowItem extends _SearchRowItem {
|
||||
final FileSearchResult file;
|
||||
_SearchFileHeaderRowItem(this.file);
|
||||
}
|
||||
|
||||
/// 文本内容检索模式下的具体代码匹配行条目
|
||||
class _SearchMatchLineRowItem extends _SearchRowItem {
|
||||
final FileSearchResult file;
|
||||
final LineMatch match;
|
||||
_SearchMatchLineRowItem(this.file, this.match);
|
||||
}
|
||||
|
||||
/// 文件内加载更多匹配项条目
|
||||
class _SearchLoadMoreMatchesRowItem extends _SearchRowItem {
|
||||
final FileSearchResult file;
|
||||
final int remainingMatchesCount;
|
||||
_SearchLoadMoreMatchesRowItem(this.file, this.remainingMatchesCount);
|
||||
}
|
||||
|
||||
/// 搜索结果底部加载更多文件条目
|
||||
class _SearchLoadMoreFilesRowItem extends _SearchRowItem {
|
||||
final int remainingFilesCount;
|
||||
_SearchLoadMoreFilesRowItem(this.remainingFilesCount);
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import 'dart:io';
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/models/project_history.dart';
|
||||
import 'package:code_editor/providers/git_provider.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/providers/run_provider.dart';
|
||||
import 'package:code_editor/providers/search_provider.dart';
|
||||
import 'package:code_editor/providers/settings_provider.dart';
|
||||
import 'package:code_editor/providers/tab_provider.dart';
|
||||
import 'package:code_editor/services/git_service.dart';
|
||||
import 'package:code_editor/services/internal_project_service.dart';
|
||||
import 'package:code_editor/widgets/code_editor_drawer.dart';
|
||||
import 'package:code_editor/widgets/file_tree_widget.dart';
|
||||
@@ -24,6 +27,8 @@ void main() {
|
||||
late TabProvider tabProvider;
|
||||
late SettingsProvider settingsProvider;
|
||||
late RunProvider runProvider;
|
||||
late SearchProvider searchProvider;
|
||||
late GitProvider gitProvider;
|
||||
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
@@ -37,6 +42,8 @@ void main() {
|
||||
tabProvider = TabProvider()..bindProjectProvider(projectProvider);
|
||||
settingsProvider = SettingsProvider();
|
||||
runProvider = RunProvider();
|
||||
searchProvider = SearchProvider()..bindRootPath(testProjectDir.path);
|
||||
gitProvider = GitProvider();
|
||||
|
||||
await projectProvider.switchProject(
|
||||
ProjectHistory(
|
||||
@@ -47,6 +54,7 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
GitService.instance.resetForTesting();
|
||||
InternalProjectService.instance.customProjectsDir = null;
|
||||
if (tempBaseDir.existsSync()) {
|
||||
tempBaseDir.deleteSync(recursive: true);
|
||||
@@ -60,6 +68,8 @@ void main() {
|
||||
ChangeNotifierProvider<TabProvider>.value(value: tabProvider),
|
||||
ChangeNotifierProvider<SettingsProvider>.value(value: settingsProvider),
|
||||
ChangeNotifierProvider<RunProvider>.value(value: runProvider),
|
||||
ChangeNotifierProvider<SearchProvider>.value(value: searchProvider),
|
||||
ChangeNotifierProvider<GitProvider>.value(value: gitProvider),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: const [
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
import 'package:code_editor/models/file_item.dart';
|
||||
import 'package:code_editor/models/git_model.dart';
|
||||
import 'package:code_editor/providers/git_provider.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/providers/tab_provider.dart';
|
||||
import 'package:code_editor/utils/git_decoration_utils.dart';
|
||||
import 'package:code_editor/widgets/file_item_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
void main() {
|
||||
group('GitDecorationUtils Tests', () {
|
||||
test('getStatusLetter returns correct letter for each type', () {
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.modified), 'M');
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.untracked), 'U');
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.added), 'A');
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.deleted), 'D');
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.unmerged), '!');
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.renamed), 'R');
|
||||
expect(GitDecorationUtils.getStatusLetter(GitFileStatusType.ignored), isNull);
|
||||
});
|
||||
|
||||
test('getPriority orders conflict > deleted > modified > added > untracked', () {
|
||||
final unmergedP = GitDecorationUtils.getPriority(GitFileStatusType.unmerged);
|
||||
final deletedP = GitDecorationUtils.getPriority(GitFileStatusType.deleted);
|
||||
final modifiedP = GitDecorationUtils.getPriority(GitFileStatusType.modified);
|
||||
final addedP = GitDecorationUtils.getPriority(GitFileStatusType.added);
|
||||
final untrackedP = GitDecorationUtils.getPriority(GitFileStatusType.untracked);
|
||||
|
||||
expect(unmergedP > deletedP, isTrue);
|
||||
expect(deletedP > modifiedP, isTrue);
|
||||
expect(modifiedP > addedP, isTrue);
|
||||
expect(addedP > untrackedP, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
group('GitProvider File Tree Map Tests', () {
|
||||
test('getFileStatus and getDirectoryStatus aggregate bottom-up correctly', () {
|
||||
final provider = GitProvider();
|
||||
const root = '/mock/repo';
|
||||
final changedFiles = [
|
||||
const GitFileStatus(
|
||||
path: '/mock/repo/lib/widgets/button.dart',
|
||||
relativePath: 'lib/widgets/button.dart',
|
||||
statusType: GitFileStatusType.modified,
|
||||
),
|
||||
const GitFileStatus(
|
||||
path: '/mock/repo/lib/main.dart',
|
||||
relativePath: 'lib/main.dart',
|
||||
statusType: GitFileStatusType.untracked,
|
||||
),
|
||||
const GitFileStatus(
|
||||
path: '/mock/repo/lib/widgets/header.dart',
|
||||
relativePath: 'lib/widgets/header.dart',
|
||||
statusType: GitFileStatusType.unmerged,
|
||||
),
|
||||
];
|
||||
|
||||
provider.setStateForTesting(
|
||||
rootPath: root,
|
||||
currentRepoPath: root,
|
||||
changedFiles: changedFiles,
|
||||
);
|
||||
|
||||
// 直接查文件
|
||||
final btnStatus = provider.getFileStatus('/mock/repo/lib/widgets/button.dart');
|
||||
expect(btnStatus, isNotNull);
|
||||
expect(btnStatus!.statusType, GitFileStatusType.modified);
|
||||
|
||||
final mainStatus = provider.getFileStatus('/mock/repo/lib/main.dart');
|
||||
expect(mainStatus, isNotNull);
|
||||
expect(mainStatus!.statusType, GitFileStatusType.untracked);
|
||||
|
||||
// 查目录:/mock/repo/lib/widgets 同时含有 modified 和 unmerged -> 聚合出 unmerged(最高优先级)
|
||||
final widgetsDirStatus = provider.getDirectoryStatus('/mock/repo/lib/widgets');
|
||||
expect(widgetsDirStatus, GitFileStatusType.unmerged);
|
||||
|
||||
// 查父级目录:/mock/repo/lib 继承最高优先级 unmerged
|
||||
final libDirStatus = provider.getDirectoryStatus('/mock/repo/lib');
|
||||
expect(libDirStatus, GitFileStatusType.unmerged);
|
||||
|
||||
// 查不存在的文件
|
||||
final absent = provider.getFileStatus('/mock/repo/lib/unknown.dart');
|
||||
expect(absent, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('FileItemWidget Git Decoration UI Tests', () {
|
||||
testWidgets('renders letter trailing for modified file and colored dot for folder', (tester) async {
|
||||
final gitProvider = GitProvider();
|
||||
final projectProvider = ProjectProvider();
|
||||
final tabProvider = TabProvider();
|
||||
|
||||
const filePath = '/test/project/file.dart';
|
||||
const dirPath = '/test/project/dir';
|
||||
|
||||
gitProvider.setStateForTesting(
|
||||
rootPath: '/test/project',
|
||||
currentRepoPath: '/test/project',
|
||||
changedFiles: [
|
||||
const GitFileStatus(
|
||||
path: filePath,
|
||||
relativePath: 'file.dart',
|
||||
statusType: GitFileStatusType.modified,
|
||||
),
|
||||
const GitFileStatus(
|
||||
path: '/test/project/dir/nested.dart',
|
||||
relativePath: 'dir/nested.dart',
|
||||
statusType: GitFileStatusType.untracked,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final fileItem = FileItem(
|
||||
path: filePath,
|
||||
name: 'file.dart',
|
||||
isDirectory: false,
|
||||
depth: 0,
|
||||
);
|
||||
|
||||
final dirItem = FileItem(
|
||||
path: dirPath,
|
||||
name: 'dir',
|
||||
isDirectory: true,
|
||||
depth: 0,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: gitProvider),
|
||||
ChangeNotifierProvider.value(value: projectProvider),
|
||||
ChangeNotifierProvider.value(value: tabProvider),
|
||||
],
|
||||
child: MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
FileItemWidget(fileItem: fileItem),
|
||||
FileItemWidget(fileItem: dirItem),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 验证文件项中出现了 'M' 标识
|
||||
expect(find.text('M'), findsOneWidget);
|
||||
|
||||
// 验证文件夹项中没有文本字母标识,但渲染了实心圆点
|
||||
expect(find.text('dir'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,9 @@
|
||||
import 'dart:io';
|
||||
import 'package:code_editor/l10n/app_localizations.dart';
|
||||
import 'package:code_editor/models/editor_tab_item.dart';
|
||||
import 'package:code_editor/models/project_history.dart';
|
||||
import 'package:code_editor/models/search_model.dart';
|
||||
import 'package:code_editor/providers/git_provider.dart';
|
||||
import 'package:code_editor/providers/project_provider.dart';
|
||||
import 'package:code_editor/providers/run_provider.dart';
|
||||
import 'package:code_editor/providers/search_provider.dart';
|
||||
@@ -13,6 +15,7 @@ import 'package:code_editor/widgets/code_editor_drawer.dart';
|
||||
import 'package:code_editor/widgets/code_editor_widget.dart';
|
||||
import 'package:code_editor/widgets/search/search_panel_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:re_editor/re_editor.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -28,6 +31,7 @@ void main() {
|
||||
late SettingsProvider settingsProvider;
|
||||
late RunProvider runProvider;
|
||||
late SearchProvider searchProvider;
|
||||
late GitProvider gitProvider;
|
||||
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
@@ -42,6 +46,7 @@ void main() {
|
||||
settingsProvider = SettingsProvider();
|
||||
runProvider = RunProvider();
|
||||
searchProvider = SearchProvider()..bindRootPath(testProjectDir.path);
|
||||
gitProvider = GitProvider();
|
||||
|
||||
await projectProvider.switchProject(
|
||||
ProjectHistory(
|
||||
@@ -197,6 +202,7 @@ void main() {
|
||||
ChangeNotifierProvider<SettingsProvider>.value(value: settingsProvider),
|
||||
ChangeNotifierProvider<RunProvider>.value(value: runProvider),
|
||||
ChangeNotifierProvider<SearchProvider>.value(value: searchProvider),
|
||||
ChangeNotifierProvider<GitProvider>.value(value: gitProvider),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -396,6 +402,7 @@ void main() {
|
||||
ChangeNotifierProvider<SettingsProvider>.value(value: settingsProvider),
|
||||
ChangeNotifierProvider<RunProvider>.value(value: runProvider),
|
||||
ChangeNotifierProvider<SearchProvider>.value(value: searchProvider),
|
||||
ChangeNotifierProvider<GitProvider>.value(value: gitProvider),
|
||||
],
|
||||
child: const MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -570,6 +577,7 @@ void main() {
|
||||
ChangeNotifierProvider<SettingsProvider>.value(value: settingsProvider),
|
||||
ChangeNotifierProvider<RunProvider>.value(value: runProvider),
|
||||
ChangeNotifierProvider<SearchProvider>.value(value: searchProvider),
|
||||
ChangeNotifierProvider<GitProvider>.value(value: gitProvider),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -658,5 +666,75 @@ void main() {
|
||||
expect(mockFiles[1].isExpanded, isTrue);
|
||||
expect(searchProvider.scrollOffset, equals(150.0));
|
||||
});
|
||||
|
||||
testWidgets('Editor focus and keyboard stability: focus is not lost or bounced during editing or search clear', (tester) async {
|
||||
final mainPath = p.normalize(p.join(testProjectDir.path, 'lib', 'main.dart'));
|
||||
final tabMain = EditorTabItem(
|
||||
path: mainPath,
|
||||
content: 'void main() {\n print("hello");\n}\n',
|
||||
originalContent: 'void main() {\n print("hello");\n}\n',
|
||||
isLoaded: true,
|
||||
isModified: false,
|
||||
);
|
||||
tabProvider.setOpenTabsForTesting([tabMain], activePath: mainPath);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<ProjectProvider>.value(value: projectProvider),
|
||||
ChangeNotifierProvider<TabProvider>.value(value: tabProvider),
|
||||
ChangeNotifierProvider<SettingsProvider>.value(value: settingsProvider),
|
||||
ChangeNotifierProvider<RunProvider>.value(value: runProvider),
|
||||
ChangeNotifierProvider<SearchProvider>.value(value: searchProvider),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
home: Scaffold(
|
||||
body: CodeEditorWidget(
|
||||
filePath: mainPath,
|
||||
rootPath: testProjectDir.path,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
await tester.pump();
|
||||
|
||||
// Find CodeEditor focus node
|
||||
final codeEditorFinder = find.byType(CodeEditor);
|
||||
expect(codeEditorFinder, findsOneWidget);
|
||||
final codeEditor = tester.widget<CodeEditor>(codeEditorFinder);
|
||||
final focusNode = codeEditor.focusNode!;
|
||||
|
||||
// 1. Focus the editor (user taps editor to bring up soft keyboard)
|
||||
focusNode.requestFocus();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(focusNode.hasFocus, isTrue);
|
||||
expect(focusNode.canRequestFocus, isTrue);
|
||||
|
||||
// 2. Perform search in text mode
|
||||
searchProvider.setMode(SearchMode.text);
|
||||
searchProvider.setQuery('void');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
// Focus should NOT be lost or disabled
|
||||
expect(focusNode.hasFocus, isTrue);
|
||||
expect(focusNode.canRequestFocus, isTrue);
|
||||
|
||||
// 3. Clear search query to empty (simulating user deleting search text)
|
||||
searchProvider.setQuery('');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
// Focus must remain rock solid! canRequestFocus must NEVER be set to false!
|
||||
expect(focusNode.hasFocus, isTrue);
|
||||
expect(focusNode.canRequestFocus, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user