This commit is contained in:
LZX committed 2026-09-23 15:17:14 +08:00
1 parent a8b7bdf606
commit 3faf9a7ae5
82 files changed
+3041 -883

No files matched your search

+49
View File
@@ -844,6 +844,10 @@
"localCompletionSubtitle": "Built-in language keywords and document lexical heuristic extraction",
"lspCompletionTitle": "Backend Language Server",
"lspCompletionSubtitle": "Request real semantic types and function parameters from background compilers",
"codeCompletionSwitchTitle": "Code Completion",
"codeCompletionSwitchSubtitle": "Real-time function, variable, and syntax suggestions while typing",
"codeDiagnosticsSwitchTitle": "Code Correction",
"codeDiagnosticsSwitchSubtitle": "Real-time syntax checking, error squiggles, and quick fixes",
"internalEngineTitle": "Runtime & Code Intelligence Engine (Ubuntu)",
"internalEngineStatusReady": "Engine Ready",
"internalEngineStatusNotReady": "Engine Not Started",
@@ -1413,6 +1417,51 @@
"gitConflictMarkWithMarkersHint": "Marking as resolved would commit them as normal content.",
"gitConflictMarkAnyway": "Mark anyway",
"gitConflictGoResolve": "Resolve first",
"gitConflictAllResolvedBadge": "All Resolved",
"gitConflictUnresolvedBadge": "{count} Unresolved",
"@gitConflictUnresolvedBadge": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"gitConflictResetToInitial": "Reset to Initial State",
"gitConflictReloadFromDisk": "Reload from Disk",
"gitConflictResolvedCommit": "Resolved · Save & Commit",
"gitConflictMoreOptions": "More Options",
"gitConflictAcceptCurrentShort": "Current",
"gitConflictAcceptIncomingShort": "Incoming",
"gitConflictAcceptBothShort": "Both",
"gitConflictCompareShort": "Compare",
"gitConflictSaveAndMarkShort": "Save & Finish",
"gitConflictMalformedBanner": "Malformed or nested conflict markers detected. Auto-resolution is disabled. Please edit manually.",
"gitConflictMalformedBadge": "Malformed",
"gitConflictCompareTitle": "Compare Conflict #{index}",
"@gitConflictCompareTitle": {
"placeholders": {
"index": {
"type": "int"
}
}
},
"gitConflictBothEmpty": "Both sides are empty",
"gitConflictCurrentWithLabel": "Current: {label}",
"@gitConflictCurrentWithLabel": {
"placeholders": {
"label": {
"type": "String"
}
}
},
"gitConflictIncomingWithLabel": "Incoming: {label}",
"@gitConflictIncomingWithLabel": {
"placeholders": {
"label": {
"type": "String"
}
}
},
"gitRemoteBranches": "Remote Branches",
"gitLocalBranches": "Local Branches",
+126
View File
@@ -2648,6 +2648,30 @@ abstract class AppLocalizations {
/// **'向后台编译器守护进程请求真实语义类型与函数参数补全'**
String get lspCompletionSubtitle;
/// No description provided for @codeCompletionSwitchTitle.
///
/// In zh, this message translates to:
/// **'代码补全'**
String get codeCompletionSwitchTitle;
/// No description provided for @codeCompletionSwitchSubtitle.
///
/// In zh, this message translates to:
/// **'输入时实时提示函数、变量与语法补全'**
String get codeCompletionSwitchSubtitle;
/// No description provided for @codeDiagnosticsSwitchTitle.
///
/// In zh, this message translates to:
/// **'代码纠错'**
String get codeDiagnosticsSwitchTitle;
/// No description provided for @codeDiagnosticsSwitchSubtitle.
///
/// In zh, this message translates to:
/// **'实时语法检查、错误波浪线提示与修复建议'**
String get codeDiagnosticsSwitchSubtitle;
/// No description provided for @internalEngineTitle.
///
/// In zh, this message translates to:
@@ -4162,6 +4186,108 @@ abstract class AppLocalizations {
/// **'去处理'**
String get gitConflictGoResolve;
/// No description provided for @gitConflictAllResolvedBadge.
///
/// In zh, this message translates to:
/// **'已全部解决'**
String get gitConflictAllResolvedBadge;
/// No description provided for @gitConflictUnresolvedBadge.
///
/// In zh, this message translates to:
/// **'{count} 未解决'**
String gitConflictUnresolvedBadge(int count);
/// No description provided for @gitConflictResetToInitial.
///
/// In zh, this message translates to:
/// **'重置为初始冲突状态'**
String get gitConflictResetToInitial;
/// No description provided for @gitConflictReloadFromDisk.
///
/// In zh, this message translates to:
/// **'重新从磁盘读取'**
String get gitConflictReloadFromDisk;
/// No description provided for @gitConflictResolvedCommit.
///
/// In zh, this message translates to:
/// **'冲突已解决 · 保存并提交'**
String get gitConflictResolvedCommit;
/// No description provided for @gitConflictMoreOptions.
///
/// In zh, this message translates to:
/// **'更多操作'**
String get gitConflictMoreOptions;
/// No description provided for @gitConflictAcceptCurrentShort.
///
/// In zh, this message translates to:
/// **'当前'**
String get gitConflictAcceptCurrentShort;
/// No description provided for @gitConflictAcceptIncomingShort.
///
/// In zh, this message translates to:
/// **'传入'**
String get gitConflictAcceptIncomingShort;
/// No description provided for @gitConflictAcceptBothShort.
///
/// In zh, this message translates to:
/// **'双方'**
String get gitConflictAcceptBothShort;
/// No description provided for @gitConflictCompareShort.
///
/// In zh, this message translates to:
/// **'对比'**
String get gitConflictCompareShort;
/// No description provided for @gitConflictSaveAndMarkShort.
///
/// In zh, this message translates to:
/// **'保存并完成'**
String get gitConflictSaveAndMarkShort;
/// No description provided for @gitConflictMalformedBanner.
///
/// In zh, this message translates to:
/// **'检测到冲突标记嵌套或不完整,自动解析已禁用,请点击下方手动编辑'**
String get gitConflictMalformedBanner;
/// No description provided for @gitConflictMalformedBadge.
///
/// In zh, this message translates to:
/// **'标记异常'**
String get gitConflictMalformedBadge;
/// No description provided for @gitConflictCompareTitle.
///
/// In zh, this message translates to:
/// **'冲突对比 · 第 {index} 处'**
String gitConflictCompareTitle(int index);
/// No description provided for @gitConflictBothEmpty.
///
/// In zh, this message translates to:
/// **'两端内容均为空'**
String get gitConflictBothEmpty;
/// No description provided for @gitConflictCurrentWithLabel.
///
/// In zh, this message translates to:
/// **'当前侧: {label}'**
String gitConflictCurrentWithLabel(String label);
/// No description provided for @gitConflictIncomingWithLabel.
///
/// In zh, this message translates to:
/// **'传入侧: {label}'**
String gitConflictIncomingWithLabel(String label);
/// No description provided for @gitRemoteBranches.
///
/// In zh, this message translates to:
+74
View File
@@ -1600,6 +1600,20 @@ class AppLocalizationsEn extends AppLocalizations {
String get lspCompletionSubtitle =>
'Request real semantic types and function parameters from background compilers';
@override
String get codeCompletionSwitchTitle => 'Code Completion';
@override
String get codeCompletionSwitchSubtitle =>
'Real-time function, variable, and syntax suggestions while typing';
@override
String get codeDiagnosticsSwitchTitle => 'Code Correction';
@override
String get codeDiagnosticsSwitchSubtitle =>
'Real-time syntax checking, error squiggles, and quick fixes';
@override
String get internalEngineTitle =>
'Runtime & Code Intelligence Engine (Ubuntu)';
@@ -2473,6 +2487,66 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get gitConflictGoResolve => 'Resolve first';
@override
String get gitConflictAllResolvedBadge => 'All Resolved';
@override
String gitConflictUnresolvedBadge(int count) {
return '$count Unresolved';
}
@override
String get gitConflictResetToInitial => 'Reset to Initial State';
@override
String get gitConflictReloadFromDisk => 'Reload from Disk';
@override
String get gitConflictResolvedCommit => 'Resolved · Save & Commit';
@override
String get gitConflictMoreOptions => 'More Options';
@override
String get gitConflictAcceptCurrentShort => 'Current';
@override
String get gitConflictAcceptIncomingShort => 'Incoming';
@override
String get gitConflictAcceptBothShort => 'Both';
@override
String get gitConflictCompareShort => 'Compare';
@override
String get gitConflictSaveAndMarkShort => 'Save & Finish';
@override
String get gitConflictMalformedBanner =>
'Malformed or nested conflict markers detected. Auto-resolution is disabled. Please edit manually.';
@override
String get gitConflictMalformedBadge => 'Malformed';
@override
String gitConflictCompareTitle(int index) {
return 'Compare Conflict #$index';
}
@override
String get gitConflictBothEmpty => 'Both sides are empty';
@override
String gitConflictCurrentWithLabel(String label) {
return 'Current: $label';
}
@override
String gitConflictIncomingWithLabel(String label) {
return 'Incoming: $label';
}
@override
String get gitRemoteBranches => 'Remote Branches';
+71
View File
@@ -1549,6 +1549,18 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get lspCompletionSubtitle => '向后台编译器守护进程请求真实语义类型与函数参数补全';
@override
String get codeCompletionSwitchTitle => '代码补全';
@override
String get codeCompletionSwitchSubtitle => '输入时实时提示函数、变量与语法补全';
@override
String get codeDiagnosticsSwitchTitle => '代码纠错';
@override
String get codeDiagnosticsSwitchSubtitle => '实时语法检查、错误波浪线提示与修复建议';
@override
String get internalEngineTitle => '代码运行与智能补全引擎 (Ubuntu)';
@@ -2399,6 +2411,65 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get gitConflictGoResolve => '去处理';
@override
String get gitConflictAllResolvedBadge => '已全部解决';
@override
String gitConflictUnresolvedBadge(int count) {
return '$count 未解决';
}
@override
String get gitConflictResetToInitial => '重置为初始冲突状态';
@override
String get gitConflictReloadFromDisk => '重新从磁盘读取';
@override
String get gitConflictResolvedCommit => '冲突已解决 · 保存并提交';
@override
String get gitConflictMoreOptions => '更多操作';
@override
String get gitConflictAcceptCurrentShort => '当前';
@override
String get gitConflictAcceptIncomingShort => '传入';
@override
String get gitConflictAcceptBothShort => '双方';
@override
String get gitConflictCompareShort => '对比';
@override
String get gitConflictSaveAndMarkShort => '保存并完成';
@override
String get gitConflictMalformedBanner => '检测到冲突标记嵌套或不完整,自动解析已禁用,请点击下方手动编辑';
@override
String get gitConflictMalformedBadge => '标记异常';
@override
String gitConflictCompareTitle(int index) {
return '冲突对比 · 第 $index 处';
}
@override
String get gitConflictBothEmpty => '两端内容均为空';
@override
String gitConflictCurrentWithLabel(String label) {
return '当前侧: $label';
}
@override
String gitConflictIncomingWithLabel(String label) {
return '传入侧: $label';
}
@override
String get gitRemoteBranches => '远端分支';
+49
View File
@@ -844,6 +844,10 @@
"localCompletionSubtitle": "包含语言内置关键字与当前文档词法启发式提取",
"lspCompletionTitle": "后端语言服务补全",
"lspCompletionSubtitle": "向后台编译器守护进程请求真实语义类型与函数参数补全",
"codeCompletionSwitchTitle": "代码补全",
"codeCompletionSwitchSubtitle": "输入时实时提示函数、变量与语法补全",
"codeDiagnosticsSwitchTitle": "代码纠错",
"codeDiagnosticsSwitchSubtitle": "实时语法检查、错误波浪线提示与修复建议",
"internalEngineTitle": "代码运行与智能补全引擎 (Ubuntu)",
"internalEngineStatusReady": "引擎已就绪",
"internalEngineStatusNotReady": "引擎未启动",
@@ -1413,6 +1417,51 @@
"gitConflictMarkWithMarkersHint": "标记为已解决会把它们当作正常内容提交进仓库。建议先处理干净。",
"gitConflictMarkAnyway": "仍然标记",
"gitConflictGoResolve": "去处理",
"gitConflictAllResolvedBadge": "已全部解决",
"gitConflictUnresolvedBadge": "{count} 未解决",
"@gitConflictUnresolvedBadge": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"gitConflictResetToInitial": "重置为初始冲突状态",
"gitConflictReloadFromDisk": "重新从磁盘读取",
"gitConflictResolvedCommit": "冲突已解决 · 保存并提交",
"gitConflictMoreOptions": "更多操作",
"gitConflictAcceptCurrentShort": "当前",
"gitConflictAcceptIncomingShort": "传入",
"gitConflictAcceptBothShort": "双方",
"gitConflictCompareShort": "对比",
"gitConflictSaveAndMarkShort": "保存并完成",
"gitConflictMalformedBanner": "检测到冲突标记嵌套或不完整,自动解析已禁用,请点击下方手动编辑",
"gitConflictMalformedBadge": "标记异常",
"gitConflictCompareTitle": "冲突对比 · 第 {index} 处",
"@gitConflictCompareTitle": {
"placeholders": {
"index": {
"type": "int"
}
}
},
"gitConflictBothEmpty": "两端内容均为空",
"gitConflictCurrentWithLabel": "当前侧: {label}",
"@gitConflictCurrentWithLabel": {
"placeholders": {
"label": {
"type": "String"
}
}
},
"gitConflictIncomingWithLabel": "传入侧: {label}",
"@gitConflictIncomingWithLabel": {
"placeholders": {
"label": {
"type": "String"
}
}
},
"gitRemoteBranches": "远端分支",
"gitLocalBranches": "本地分支",
+38 -2
View File
@@ -46,7 +46,9 @@ class SettingsProvider extends ChangeNotifier {
static const String _keyShowHiddenFiles = 'show_hidden_files'; //显示隐藏文件
//代码补全
static const String _keyEnableLspCompletion = 'enable_lsp_completion'; //LSP智能代码补全启用
static const String _keyEnableLspCompletion = 'enable_lsp_completion'; //LSP智能代码补全总开关
static const String _keyEnableCodeCompletion = 'enable_code_completion'; //代码补全子开关
static const String _keyEnableCodeDiagnostics = 'enable_code_diagnostics'; //代码纠错子开关
//语言
static const String _keyAppLocale = 'app_locale';
@@ -83,6 +85,8 @@ class SettingsProvider extends ChangeNotifier {
VirtualKeyboardConfig _terminalKeyboardConfig = VirtualKeyboardConfig.defaultTerminalConfiguration();
bool _showHiddenFiles = true;
bool _enableLspCompletion = true;
bool _enableCodeCompletion = true;
bool _enableCodeDiagnostics = true;
ContainerRuntimeMode _containerRuntimeMode = ContainerRuntimeMode.auto;
bool _hasPromptedRootRequest = false;
Locale? _locale;
@@ -91,6 +95,8 @@ class SettingsProvider extends ChangeNotifier {
@Deprecated('本地补全已完全移除')
bool get enableLocalCompletion => false;
bool get enableLspCompletion => _enableLspCompletion;
bool get enableCodeCompletion => _enableCodeCompletion;
bool get enableCodeDiagnostics => _enableCodeDiagnostics;
ContainerRuntimeMode get containerRuntimeMode => _containerRuntimeMode;
bool get hasPromptedRootRequest => _hasPromptedRootRequest;
@@ -323,6 +329,14 @@ class SettingsProvider extends ChangeNotifier {
if (savedEnableLspCompletion != null) {
_enableLspCompletion = savedEnableLspCompletion;
}
final savedEnableCodeCompletion = prefs.getBool(_keyEnableCodeCompletion);
if (savedEnableCodeCompletion != null) {
_enableCodeCompletion = savedEnableCodeCompletion;
}
final savedEnableCodeDiagnostics = prefs.getBool(_keyEnableCodeDiagnostics);
if (savedEnableCodeDiagnostics != null) {
_enableCodeDiagnostics = savedEnableCodeDiagnostics;
}
//设置语言
final savedLocale = prefs.getString(_keyAppLocale);
@@ -549,7 +563,7 @@ class SettingsProvider extends ChangeNotifier {
@Deprecated('本地补全已完全移除')
Future<void> setEnableLocalCompletion(bool enable) async {}
/// 设置是否启用LSP后端代码补全
/// 设置是否启用LSP后端代码补全(总开关)
Future<void> setEnableLspCompletion(bool enable) async {
if (_enableLspCompletion == enable) return;
_enableLspCompletion = enable;
@@ -559,4 +573,26 @@ class SettingsProvider extends ChangeNotifier {
await prefs.setBool(_keyEnableLspCompletion, enable);
} catch (_) {}
}
/// 设置是否启用代码补全子功能
Future<void> setEnableCodeCompletion(bool enable) async {
if (_enableCodeCompletion == enable) return;
_enableCodeCompletion = enable;
notifyListeners();
try {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_keyEnableCodeCompletion, enable);
} catch (_) {}
}
/// 设置是否启用代码纠错子功能
Future<void> setEnableCodeDiagnostics(bool enable) async {
if (_enableCodeDiagnostics == enable) return;
_enableCodeDiagnostics = enable;
notifyListeners();
try {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_keyEnableCodeDiagnostics, enable);
} catch (_) {}
}
}
+1 -1
View File
@@ -391,7 +391,7 @@ class DistroManager {
}
}
static const MethodChannel _nativeChannel = MethodChannel('com.example.code_editor/native');
static const MethodChannel _nativeChannel = MethodChannel('com.lzxnone.code_editor/native');
String? _cachedProotPath;
String? _cachedNativeDir;
+42 -1
View File
@@ -290,6 +290,8 @@ class _CodeCompletionManagementViewState
if (settings == null) return const SizedBox.shrink();
final colorScheme = theme.colorScheme;
final isMasterEnabled = settings.enableLspCompletion;
return Card(
elevation: 0,
color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.35),
@@ -312,12 +314,51 @@ class _CodeCompletionManagementViewState
),
),
),
// 语言服务总开关
SwitchListTile(
key: const ValueKey('lsp_master_switch'),
secondary: const Icon(Icons.hub_outlined),
title: Text(l10n.lspCompletionTitle),
value: settings.enableLspCompletion,
subtitle: Text(l10n.lspCompletionSubtitle),
value: isMasterEnabled,
onChanged: (val) => settings.setEnableLspCompletion(val),
),
Divider(
height: 1,
indent: 16,
endIndent: 16,
color: colorScheme.outlineVariant.withValues(alpha: 0.4),
),
// 分开关 1:代码补全
SwitchListTile(
key: const ValueKey('code_completion_sub_switch'),
contentPadding: const EdgeInsets.only(left: 32, right: 16),
secondary: Icon(
Icons.auto_awesome_outlined,
color: isMasterEnabled ? null : colorScheme.onSurface.withValues(alpha: 0.38),
),
title: Text(l10n.codeCompletionSwitchTitle),
subtitle: Text(l10n.codeCompletionSwitchSubtitle),
value: settings.enableCodeCompletion,
onChanged: isMasterEnabled
? (val) => settings.setEnableCodeCompletion(val)
: null,
),
// 分开关 2:代码纠错
SwitchListTile(
key: const ValueKey('code_diagnostics_sub_switch'),
contentPadding: const EdgeInsets.only(left: 32, right: 16),
secondary: Icon(
Icons.spellcheck_rounded,
color: isMasterEnabled ? null : colorScheme.onSurface.withValues(alpha: 0.38),
),
title: Text(l10n.codeDiagnosticsSwitchTitle),
subtitle: Text(l10n.codeDiagnosticsSwitchSubtitle),
value: settings.enableCodeDiagnostics,
onChanged: isMasterEnabled
? (val) => settings.setEnableCodeDiagnostics(val)
: null,
),
],
),
),
+11
View File
@@ -38,6 +38,16 @@ import 'package:provider/provider.dart';
class MainView extends StatefulWidget {
const MainView({super.key});
/// 全局主页面 Scaffold Key,用于从任何弹窗、底部面板或子页面关闭主界面抽屉侧边栏
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
/// 方便调用的关闭主界面侧边栏抽屉辅助方法
static void closeDrawerIfOpen() {
if (scaffoldKey.currentState?.isDrawerOpen ?? false) {
scaffoldKey.currentState?.closeDrawer();
}
}
/// 清除指定语言或全部语言的防打扰提示记录(卸载组件后恢复提示资格并重置当前文件检查)
static void clearPromptedLanguage(String? languageId) {
_MainViewState.clearPromptedLanguage(languageId);
@@ -653,6 +663,7 @@ class _MainViewState extends State<MainView> {
}
},
child: Scaffold(
key: MainView.scaffoldKey,
appBar: CodeEditorAppBar(
filePath: currentFile,
rootPath: rootPath,
+17 -2
View File
@@ -1020,6 +1020,13 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
required TextSpan textSpan,
required TextStyle style,
}) {
try {
final settings = _getSettingsProvider(context);
if (!settings.enableLspCompletion || !settings.enableCodeDiagnostics) {
return textSpan;
}
} catch (_) {}
return _diagnosticController.buildDiagnosticSpans(
context: context,
filePath: _currentLoadedPath ?? widget.filePath,
@@ -1218,6 +1225,8 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
bool showLineNumbers = true;
bool pinLineNumbers = true;
bool enableLspCompletion = true;
bool enableCodeCompletion = true;
bool enableCodeDiagnostics = true;
try {
final settings = _getSettingsProvider(context, listen: true);
activeTheme = settings.editorTheme;
@@ -1229,6 +1238,8 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
keyboardConfig = settings.virtualKeyboardConfig;
activeEditorFont = settings.editorFont;
enableLspCompletion = settings.enableLspCompletion;
enableCodeCompletion = settings.enableCodeCompletion;
enableCodeDiagnostics = settings.enableCodeDiagnostics;
if (_currentIndentSize != null && _currentIndentSize != settings.indentSize) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _loadFileContent();
@@ -1236,6 +1247,9 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
}
} catch (_) {}
final bool effectiveCompletion = enableLspCompletion && enableCodeCompletion;
final bool effectiveDiagnostics = enableLspCompletion && enableCodeDiagnostics;
final double displayFontSize = _activeZoomFontSize ?? activeFontSize;
return Container(
@@ -1262,7 +1276,7 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
final promptsBuilder = SmartCodeAutocompletePromptsBuilder(
controller: controller,
filePath: _currentLoadedPath ?? widget.filePath,
enableLspCompletion: enableLspCompletion,
enableLspCompletion: effectiveCompletion,
);
return EditorOverlayScope(
key: ValueKey(_currentLoadedPath),
@@ -1316,6 +1330,7 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
controller: editingController,
notifier: notifier,
lineDecorationBuilder: (lineIndex) {
if (!effectiveDiagnostics) return null;
final filePath = _currentLoadedPath ?? widget.filePath;
if (filePath == null) return null;
final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine(filePath, lineIndex);
@@ -1406,7 +1421,7 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
),
),
),
if (_currentCursorLine >= 0 && (_currentLoadedPath ?? widget.filePath) != null) ...[
if (effectiveDiagnostics && _currentCursorLine >= 0 && (_currentLoadedPath ?? widget.filePath) != null) ...[
Builder(
builder: (ctx) {
final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine(
+12
View File
@@ -68,6 +68,18 @@ class ConflictLine {
role == ConflictLineRole.oursContent ||
role == ConflictLineRole.baseContent ||
role == ConflictLineRole.theirsContent;
bool get isOurs =>
role == ConflictLineRole.oursHeader ||
role == ConflictLineRole.oursContent;
bool get isTheirs =>
role == ConflictLineRole.theirsHeader ||
role == ConflictLineRole.theirsContent;
bool get isBase =>
role == ConflictLineRole.baseHeader ||
role == ConflictLineRole.baseContent;
}
/// 把冲突文件内容摊平成可渲染的行序列
+4 -8
View File
@@ -7,6 +7,7 @@ import '../../providers/git_provider.dart';
import '../../providers/tab_provider.dart';
import '../../utils/dialog_utils.dart';
import '../../utils/git_error_mapper.dart';
import '../../views/main_view.dart';
import 'git_conflict_resolve_page.dart';
/// 冲突解决面板(底部弹出)
@@ -518,9 +519,6 @@ class _ConflictFileTile extends StatelessWidget {
await provider.refreshConflictState();
if (!context.mounted) return;
// 先收起面板与抽屉,再压入解决页 —— 否则返回时层级会错乱
Navigator.of(context).maybePop();
await Navigator.of(context).push(
GitConflictResolvePage.route(file: file, gitProvider: provider),
);
@@ -539,11 +537,9 @@ class _ConflictFileTile extends StatelessWidget {
await tabProvider.openFile(file.absolutePath);
if (!context.mounted) return;
// 先收起 bottom sheet 面板,再显式关闭抽屉。
// 这里不能用连续两次 maybePop():抽屉是 Scaffold 管理的路由,
// 用 closeDrawer() 才是项目内一致且可靠的做法(见 file_item_widget)。
Navigator.of(context).maybePop();
Scaffold.maybeOf(context)?.closeDrawer();
// 先收起 bottom sheet 冲突面板,再关闭侧边栏抽屉,直达主代码编辑区
Navigator.of(context).pop();
MainView.closeDrawerIfOpen();
}
Future<void> _takeSide(
File diff suppressed because it is too large. Load diff