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

No files matched your search

+7 -2
View File
@@ -6,7 +6,7 @@ plugins {
} }
android { android {
namespace = "com.example.code_editor" namespace = "com.lzxnone.code_editor"
compileSdk = 37 compileSdk = 37
ndkVersion = "28.2.13676358" ndkVersion = "28.2.13676358"
@@ -21,7 +21,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.code_editor" applicationId = "com.lzxnone.code_editor"
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config. // For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion minSdk = flutter.minSdkVersion
@@ -43,6 +43,11 @@ android {
useLegacyPackaging = true useLegacyPackaging = true
} }
} }
lint {
abortOnError = false
checkReleaseBuilds = false
}
} }
flutter { flutter {
+2 -2
View File
@@ -10,9 +10,9 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application <application
android:label="code_editor" android:label="LN 代码编辑器"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/launcher_icon"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:extractNativeLibs="true"> android:extractNativeLibs="true">
<activity <activity
@@ -1,4 +1,4 @@
package com.example.code_editor package com.lzxnone.code_editor
import android.database.Cursor import android.database.Cursor
import android.database.MatrixCursor import android.database.MatrixCursor
@@ -1,11 +1,11 @@
package com.example.code_editor package com.lzxnone.code_editor
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
class MainActivity : FlutterActivity() { class MainActivity : FlutterActivity() {
private val CHANNEL = "com.example.code_editor/native" private val CHANNEL = "com.lzxnone.code_editor/native"
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine) super.configureFlutterEngine(flutterEngine)
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground>
<inset
android:drawable="@drawable/ic_launcher_foreground"
android:inset="16%" />
</foreground>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#121214</color>
</resources>
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+8 -8
View File
@@ -368,7 +368,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -401,7 +401,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
@@ -416,7 +416,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
@@ -427,7 +427,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
@@ -484,7 +484,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
@@ -547,7 +547,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -569,7 +569,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@@ -1,122 +1 @@
{ {"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

After

Width:  |  Height:  |  Size: 979 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

+1 -1
View File
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>Code Editor</string> <string>LN 代码编辑器</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
+49
View File
@@ -844,6 +844,10 @@
"localCompletionSubtitle": "Built-in language keywords and document lexical heuristic extraction", "localCompletionSubtitle": "Built-in language keywords and document lexical heuristic extraction",
"lspCompletionTitle": "Backend Language Server", "lspCompletionTitle": "Backend Language Server",
"lspCompletionSubtitle": "Request real semantic types and function parameters from background compilers", "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)", "internalEngineTitle": "Runtime & Code Intelligence Engine (Ubuntu)",
"internalEngineStatusReady": "Engine Ready", "internalEngineStatusReady": "Engine Ready",
"internalEngineStatusNotReady": "Engine Not Started", "internalEngineStatusNotReady": "Engine Not Started",
@@ -1413,6 +1417,51 @@
"gitConflictMarkWithMarkersHint": "Marking as resolved would commit them as normal content.", "gitConflictMarkWithMarkersHint": "Marking as resolved would commit them as normal content.",
"gitConflictMarkAnyway": "Mark anyway", "gitConflictMarkAnyway": "Mark anyway",
"gitConflictGoResolve": "Resolve first", "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", "gitRemoteBranches": "Remote Branches",
"gitLocalBranches": "Local Branches", "gitLocalBranches": "Local Branches",
+126
View File
@@ -2648,6 +2648,30 @@ abstract class AppLocalizations {
/// **'向后台编译器守护进程请求真实语义类型与函数参数补全'** /// **'向后台编译器守护进程请求真实语义类型与函数参数补全'**
String get lspCompletionSubtitle; 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. /// No description provided for @internalEngineTitle.
/// ///
/// In zh, this message translates to: /// In zh, this message translates to:
@@ -4162,6 +4186,108 @@ abstract class AppLocalizations {
/// **'去处理'** /// **'去处理'**
String get gitConflictGoResolve; 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. /// No description provided for @gitRemoteBranches.
/// ///
/// In zh, this message translates to: /// In zh, this message translates to:
+74
View File
@@ -1600,6 +1600,20 @@ class AppLocalizationsEn extends AppLocalizations {
String get lspCompletionSubtitle => String get lspCompletionSubtitle =>
'Request real semantic types and function parameters from background compilers'; '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 @override
String get internalEngineTitle => String get internalEngineTitle =>
'Runtime & Code Intelligence Engine (Ubuntu)'; 'Runtime & Code Intelligence Engine (Ubuntu)';
@@ -2473,6 +2487,66 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get gitConflictGoResolve => 'Resolve first'; 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 @override
String get gitRemoteBranches => 'Remote Branches'; String get gitRemoteBranches => 'Remote Branches';
+71
View File
@@ -1549,6 +1549,18 @@ class AppLocalizationsZh extends AppLocalizations {
@override @override
String get lspCompletionSubtitle => '向后台编译器守护进程请求真实语义类型与函数参数补全'; String get lspCompletionSubtitle => '向后台编译器守护进程请求真实语义类型与函数参数补全';
@override
String get codeCompletionSwitchTitle => '代码补全';
@override
String get codeCompletionSwitchSubtitle => '输入时实时提示函数、变量与语法补全';
@override
String get codeDiagnosticsSwitchTitle => '代码纠错';
@override
String get codeDiagnosticsSwitchSubtitle => '实时语法检查、错误波浪线提示与修复建议';
@override @override
String get internalEngineTitle => '代码运行与智能补全引擎 (Ubuntu)'; String get internalEngineTitle => '代码运行与智能补全引擎 (Ubuntu)';
@@ -2399,6 +2411,65 @@ class AppLocalizationsZh extends AppLocalizations {
@override @override
String get gitConflictGoResolve => '去处理'; 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 @override
String get gitRemoteBranches => '远端分支'; String get gitRemoteBranches => '远端分支';
+49
View File
@@ -844,6 +844,10 @@
"localCompletionSubtitle": "包含语言内置关键字与当前文档词法启发式提取", "localCompletionSubtitle": "包含语言内置关键字与当前文档词法启发式提取",
"lspCompletionTitle": "后端语言服务补全", "lspCompletionTitle": "后端语言服务补全",
"lspCompletionSubtitle": "向后台编译器守护进程请求真实语义类型与函数参数补全", "lspCompletionSubtitle": "向后台编译器守护进程请求真实语义类型与函数参数补全",
"codeCompletionSwitchTitle": "代码补全",
"codeCompletionSwitchSubtitle": "输入时实时提示函数、变量与语法补全",
"codeDiagnosticsSwitchTitle": "代码纠错",
"codeDiagnosticsSwitchSubtitle": "实时语法检查、错误波浪线提示与修复建议",
"internalEngineTitle": "代码运行与智能补全引擎 (Ubuntu)", "internalEngineTitle": "代码运行与智能补全引擎 (Ubuntu)",
"internalEngineStatusReady": "引擎已就绪", "internalEngineStatusReady": "引擎已就绪",
"internalEngineStatusNotReady": "引擎未启动", "internalEngineStatusNotReady": "引擎未启动",
@@ -1413,6 +1417,51 @@
"gitConflictMarkWithMarkersHint": "标记为已解决会把它们当作正常内容提交进仓库。建议先处理干净。", "gitConflictMarkWithMarkersHint": "标记为已解决会把它们当作正常内容提交进仓库。建议先处理干净。",
"gitConflictMarkAnyway": "仍然标记", "gitConflictMarkAnyway": "仍然标记",
"gitConflictGoResolve": "去处理", "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": "远端分支", "gitRemoteBranches": "远端分支",
"gitLocalBranches": "本地分支", "gitLocalBranches": "本地分支",
+38 -2
View File
@@ -46,7 +46,9 @@ class SettingsProvider extends ChangeNotifier {
static const String _keyShowHiddenFiles = 'show_hidden_files'; //显示隐藏文件 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'; static const String _keyAppLocale = 'app_locale';
@@ -83,6 +85,8 @@ class SettingsProvider extends ChangeNotifier {
VirtualKeyboardConfig _terminalKeyboardConfig = VirtualKeyboardConfig.defaultTerminalConfiguration(); VirtualKeyboardConfig _terminalKeyboardConfig = VirtualKeyboardConfig.defaultTerminalConfiguration();
bool _showHiddenFiles = true; bool _showHiddenFiles = true;
bool _enableLspCompletion = true; bool _enableLspCompletion = true;
bool _enableCodeCompletion = true;
bool _enableCodeDiagnostics = true;
ContainerRuntimeMode _containerRuntimeMode = ContainerRuntimeMode.auto; ContainerRuntimeMode _containerRuntimeMode = ContainerRuntimeMode.auto;
bool _hasPromptedRootRequest = false; bool _hasPromptedRootRequest = false;
Locale? _locale; Locale? _locale;
@@ -91,6 +95,8 @@ class SettingsProvider extends ChangeNotifier {
@Deprecated('本地补全已完全移除') @Deprecated('本地补全已完全移除')
bool get enableLocalCompletion => false; bool get enableLocalCompletion => false;
bool get enableLspCompletion => _enableLspCompletion; bool get enableLspCompletion => _enableLspCompletion;
bool get enableCodeCompletion => _enableCodeCompletion;
bool get enableCodeDiagnostics => _enableCodeDiagnostics;
ContainerRuntimeMode get containerRuntimeMode => _containerRuntimeMode; ContainerRuntimeMode get containerRuntimeMode => _containerRuntimeMode;
bool get hasPromptedRootRequest => _hasPromptedRootRequest; bool get hasPromptedRootRequest => _hasPromptedRootRequest;
@@ -323,6 +329,14 @@ class SettingsProvider extends ChangeNotifier {
if (savedEnableLspCompletion != null) { if (savedEnableLspCompletion != null) {
_enableLspCompletion = savedEnableLspCompletion; _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); final savedLocale = prefs.getString(_keyAppLocale);
@@ -549,7 +563,7 @@ class SettingsProvider extends ChangeNotifier {
@Deprecated('本地补全已完全移除') @Deprecated('本地补全已完全移除')
Future<void> setEnableLocalCompletion(bool enable) async {} Future<void> setEnableLocalCompletion(bool enable) async {}
/// 设置是否启用LSP后端代码补全 /// 设置是否启用LSP后端代码补全(总开关)
Future<void> setEnableLspCompletion(bool enable) async { Future<void> setEnableLspCompletion(bool enable) async {
if (_enableLspCompletion == enable) return; if (_enableLspCompletion == enable) return;
_enableLspCompletion = enable; _enableLspCompletion = enable;
@@ -559,4 +573,26 @@ class SettingsProvider extends ChangeNotifier {
await prefs.setBool(_keyEnableLspCompletion, enable); await prefs.setBool(_keyEnableLspCompletion, enable);
} catch (_) {} } 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? _cachedProotPath;
String? _cachedNativeDir; String? _cachedNativeDir;
+42 -1
View File
@@ -290,6 +290,8 @@ class _CodeCompletionManagementViewState
if (settings == null) return const SizedBox.shrink(); if (settings == null) return const SizedBox.shrink();
final colorScheme = theme.colorScheme; final colorScheme = theme.colorScheme;
final isMasterEnabled = settings.enableLspCompletion;
return Card( return Card(
elevation: 0, elevation: 0,
color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.35), color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.35),
@@ -312,12 +314,51 @@ class _CodeCompletionManagementViewState
), ),
), ),
), ),
// 语言服务总开关
SwitchListTile( SwitchListTile(
key: const ValueKey('lsp_master_switch'),
secondary: const Icon(Icons.hub_outlined), secondary: const Icon(Icons.hub_outlined),
title: Text(l10n.lspCompletionTitle), title: Text(l10n.lspCompletionTitle),
value: settings.enableLspCompletion, subtitle: Text(l10n.lspCompletionSubtitle),
value: isMasterEnabled,
onChanged: (val) => settings.setEnableLspCompletion(val), 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 { class MainView extends StatefulWidget {
const MainView({super.key}); 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) { static void clearPromptedLanguage(String? languageId) {
_MainViewState.clearPromptedLanguage(languageId); _MainViewState.clearPromptedLanguage(languageId);
@@ -653,6 +663,7 @@ class _MainViewState extends State<MainView> {
} }
}, },
child: Scaffold( child: Scaffold(
key: MainView.scaffoldKey,
appBar: CodeEditorAppBar( appBar: CodeEditorAppBar(
filePath: currentFile, filePath: currentFile,
rootPath: rootPath, rootPath: rootPath,
+17 -2
View File
@@ -1020,6 +1020,13 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
required TextSpan textSpan, required TextSpan textSpan,
required TextStyle style, required TextStyle style,
}) { }) {
try {
final settings = _getSettingsProvider(context);
if (!settings.enableLspCompletion || !settings.enableCodeDiagnostics) {
return textSpan;
}
} catch (_) {}
return _diagnosticController.buildDiagnosticSpans( return _diagnosticController.buildDiagnosticSpans(
context: context, context: context,
filePath: _currentLoadedPath ?? widget.filePath, filePath: _currentLoadedPath ?? widget.filePath,
@@ -1218,6 +1225,8 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
bool showLineNumbers = true; bool showLineNumbers = true;
bool pinLineNumbers = true; bool pinLineNumbers = true;
bool enableLspCompletion = true; bool enableLspCompletion = true;
bool enableCodeCompletion = true;
bool enableCodeDiagnostics = true;
try { try {
final settings = _getSettingsProvider(context, listen: true); final settings = _getSettingsProvider(context, listen: true);
activeTheme = settings.editorTheme; activeTheme = settings.editorTheme;
@@ -1229,6 +1238,8 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
keyboardConfig = settings.virtualKeyboardConfig; keyboardConfig = settings.virtualKeyboardConfig;
activeEditorFont = settings.editorFont; activeEditorFont = settings.editorFont;
enableLspCompletion = settings.enableLspCompletion; enableLspCompletion = settings.enableLspCompletion;
enableCodeCompletion = settings.enableCodeCompletion;
enableCodeDiagnostics = settings.enableCodeDiagnostics;
if (_currentIndentSize != null && _currentIndentSize != settings.indentSize) { if (_currentIndentSize != null && _currentIndentSize != settings.indentSize) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _loadFileContent(); if (mounted) _loadFileContent();
@@ -1236,6 +1247,9 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
} }
} catch (_) {} } catch (_) {}
final bool effectiveCompletion = enableLspCompletion && enableCodeCompletion;
final bool effectiveDiagnostics = enableLspCompletion && enableCodeDiagnostics;
final double displayFontSize = _activeZoomFontSize ?? activeFontSize; final double displayFontSize = _activeZoomFontSize ?? activeFontSize;
return Container( return Container(
@@ -1262,7 +1276,7 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
final promptsBuilder = SmartCodeAutocompletePromptsBuilder( final promptsBuilder = SmartCodeAutocompletePromptsBuilder(
controller: controller, controller: controller,
filePath: _currentLoadedPath ?? widget.filePath, filePath: _currentLoadedPath ?? widget.filePath,
enableLspCompletion: enableLspCompletion, enableLspCompletion: effectiveCompletion,
); );
return EditorOverlayScope( return EditorOverlayScope(
key: ValueKey(_currentLoadedPath), key: ValueKey(_currentLoadedPath),
@@ -1316,6 +1330,7 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
controller: editingController, controller: editingController,
notifier: notifier, notifier: notifier,
lineDecorationBuilder: (lineIndex) { lineDecorationBuilder: (lineIndex) {
if (!effectiveDiagnostics) return null;
final filePath = _currentLoadedPath ?? widget.filePath; final filePath = _currentLoadedPath ?? widget.filePath;
if (filePath == null) return null; if (filePath == null) return null;
final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine(filePath, lineIndex); 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(
builder: (ctx) { builder: (ctx) {
final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine( final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine(
+12
View File
@@ -68,6 +68,18 @@ class ConflictLine {
role == ConflictLineRole.oursContent || role == ConflictLineRole.oursContent ||
role == ConflictLineRole.baseContent || role == ConflictLineRole.baseContent ||
role == ConflictLineRole.theirsContent; 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 '../../providers/tab_provider.dart';
import '../../utils/dialog_utils.dart'; import '../../utils/dialog_utils.dart';
import '../../utils/git_error_mapper.dart'; import '../../utils/git_error_mapper.dart';
import '../../views/main_view.dart';
import 'git_conflict_resolve_page.dart'; import 'git_conflict_resolve_page.dart';
/// 冲突解决面板(底部弹出) /// 冲突解决面板(底部弹出)
@@ -518,9 +519,6 @@ class _ConflictFileTile extends StatelessWidget {
await provider.refreshConflictState(); await provider.refreshConflictState();
if (!context.mounted) return; if (!context.mounted) return;
// 先收起面板与抽屉,再压入解决页 —— 否则返回时层级会错乱
Navigator.of(context).maybePop();
await Navigator.of(context).push( await Navigator.of(context).push(
GitConflictResolvePage.route(file: file, gitProvider: provider), GitConflictResolvePage.route(file: file, gitProvider: provider),
); );
@@ -539,11 +537,9 @@ class _ConflictFileTile extends StatelessWidget {
await tabProvider.openFile(file.absolutePath); await tabProvider.openFile(file.absolutePath);
if (!context.mounted) return; if (!context.mounted) return;
// 先收起 bottom sheet 面板,再显式关闭抽屉。 // 先收起 bottom sheet 冲突面板,再关闭侧边栏抽屉,直达主代码编辑区
// 这里不能用连续两次 maybePop():抽屉是 Scaffold 管理的路由, Navigator.of(context).pop();
// 用 closeDrawer() 才是项目内一致且可靠的做法(见 file_item_widget)。 MainView.closeDrawerIfOpen();
Navigator.of(context).maybePop();
Scaffold.maybeOf(context)?.closeDrawer();
} }
Future<void> _takeSide( Future<void> _takeSide(
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -7,7 +7,7 @@ project(runner LANGUAGES CXX)
set(BINARY_NAME "code_editor") set(BINARY_NAME "code_editor")
# The unique GTK application identifier for this application. See: # The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID # https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "com.example.code_editor") set(APPLICATION_ID "com.lzxnone.code_editor")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake. # versions of CMake.
+3 -3
View File
@@ -385,7 +385,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor";
@@ -399,7 +399,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor";
@@ -413,7 +413,7 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests; PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor";
@@ -1,68 +1,68 @@
{ {
"images" : [ "info": {
{ "version": 1,
"size" : "16x16", "author": "xcode"
"idiom" : "mac",
"filename" : "app_icon_16.png",
"scale" : "1x"
}, },
{ "images": [
"size" : "16x16", {
"idiom" : "mac", "size": "16x16",
"filename" : "app_icon_32.png", "idiom": "mac",
"scale" : "2x" "filename": "app_icon_16.png",
}, "scale": "1x"
{ },
"size" : "32x32", {
"idiom" : "mac", "size": "16x16",
"filename" : "app_icon_32.png", "idiom": "mac",
"scale" : "1x" "filename": "app_icon_32.png",
}, "scale": "2x"
{ },
"size" : "32x32", {
"idiom" : "mac", "size": "32x32",
"filename" : "app_icon_64.png", "idiom": "mac",
"scale" : "2x" "filename": "app_icon_32.png",
}, "scale": "1x"
{ },
"size" : "128x128", {
"idiom" : "mac", "size": "32x32",
"filename" : "app_icon_128.png", "idiom": "mac",
"scale" : "1x" "filename": "app_icon_64.png",
}, "scale": "2x"
{ },
"size" : "128x128", {
"idiom" : "mac", "size": "128x128",
"filename" : "app_icon_256.png", "idiom": "mac",
"scale" : "2x" "filename": "app_icon_128.png",
}, "scale": "1x"
{ },
"size" : "256x256", {
"idiom" : "mac", "size": "128x128",
"filename" : "app_icon_256.png", "idiom": "mac",
"scale" : "1x" "filename": "app_icon_256.png",
}, "scale": "2x"
{ },
"size" : "256x256", {
"idiom" : "mac", "size": "256x256",
"filename" : "app_icon_512.png", "idiom": "mac",
"scale" : "2x" "filename": "app_icon_256.png",
}, "scale": "1x"
{ },
"size" : "512x512", {
"idiom" : "mac", "size": "256x256",
"filename" : "app_icon_512.png", "idiom": "mac",
"scale" : "1x" "filename": "app_icon_512.png",
}, "scale": "2x"
{ },
"size" : "512x512", {
"idiom" : "mac", "size": "512x512",
"filename" : "app_icon_1024.png", "idiom": "mac",
"scale" : "2x" "filename": "app_icon_512.png",
} "scale": "1x"
], },
"info" : { {
"version" : 1, "size": "512x512",
"author" : "xcode" "idiom": "mac",
} "filename": "app_icon_1024.png",
"scale": "2x"
}
]
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 854 B

+3 -3
View File
@@ -5,10 +5,10 @@
// 'flutter create' template. // 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window. // The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = code_editor PRODUCT_NAME = LN 代码编辑器
// The application's bundle identifier // The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.code_editor
// The copyright displayed in application information // The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. PRODUCT_COPYRIGHT = Copyright © 2026 com.lzxnone. All rights reserved.
+56
View File
@@ -41,6 +41,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.1" version: "1.4.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
url: "https://pub.dev"
source: hosted
version: "0.4.2"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@@ -142,6 +158,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
sha256: "10f13781741a2e3972126fae08393d3c4e01fa4cd7473326b94b72cf594195e7"
url: "https://pub.dev"
source: hosted
version: "0.14.4"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
@@ -189,6 +213,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.0" version: "2.2.0"
image:
dependency: transitive
description:
name: image
sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d
url: "https://pub.dev"
source: hosted
version: "4.3.0"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -237,6 +269,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
url: "https://pub.dev"
source: hosted
version: "4.12.0"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
@@ -429,6 +469,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.2" version: "0.2.2"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
url: "https://pub.dev"
source: hosted
version: "7.0.2"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@@ -713,6 +761,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
url: "https://pub.dev"
source: hosted
version: "6.6.1"
xterm: xterm:
dependency: "direct main" dependency: "direct main"
description: description:
+19
View File
@@ -39,6 +39,7 @@ dev_dependencies:
sdk: flutter sdk: flutter
flutter_lints: ^6.0.0 flutter_lints: ^6.0.0
flutter_launcher_icons: ^0.14.3
flutter: flutter:
@@ -73,3 +74,21 @@ flutter:
weight: 500 weight: 500
- asset: assets/fonts/FiraCodeNerdFontMono-Bold.ttf - asset: assets/fonts/FiraCodeNerdFontMono-Bold.ttf
weight: 700 weight: 700
flutter_launcher_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/app_icon.png"
min_sdk_android: 21
adaptive_icon_background: "#121214"
adaptive_icon_foreground: "assets/icon/app_icon_foreground.png"
web:
generate: true
image_path: "assets/icon/app_icon.png"
windows:
generate: true
image_path: "assets/icon/app_icon.png"
icon_size: 48
macos:
generate: true
image_path: "assets/icon/app_icon.png"
@@ -0,0 +1,124 @@
import 'package:code_editor/l10n/app_localizations.dart';
import 'package:code_editor/providers/settings_provider.dart';
import 'package:code_editor/views/code_completion_management_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late SettingsProvider settingsProvider;
setUp(() async {
SharedPreferences.setMockInitialValues({});
settingsProvider = SettingsProvider();
await settingsProvider.init();
});
Widget buildTestWidget({Locale locale = const Locale('zh')}) {
return ChangeNotifierProvider<SettingsProvider>.value(
value: settingsProvider,
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: locale,
home: const CodeCompletionManagementView(),
),
);
}
testWidgets('代码补全管理页面展示总开关与两个分开关,且支持中文多语言', (tester) async {
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
// 1. 验证总开关
final masterSwitch = find.byKey(const ValueKey('lsp_master_switch'));
expect(masterSwitch, findsOneWidget);
expect(find.text('后端语言服务补全'), findsOneWidget);
// 2. 验证分开关 1:代码补全
final completionSwitch = find.byKey(const ValueKey('code_completion_sub_switch'));
expect(completionSwitch, findsOneWidget);
expect(find.text('代码补全'), findsOneWidget);
expect(find.text('输入时实时提示函数、变量与语法补全'), findsOneWidget);
// 3. 验证分开关 2:代码纠错
final diagnosticsSwitch = find.byKey(const ValueKey('code_diagnostics_sub_switch'));
expect(diagnosticsSwitch, findsOneWidget);
expect(find.text('代码纠错'), findsOneWidget);
expect(find.text('实时语法检查、错误波浪线提示与修复建议'), findsOneWidget);
// 4. 默认总开关开启时,两个分开关均为启用状态 (onChanged != null)
final completionTile = tester.widget<SwitchListTile>(completionSwitch);
final diagnosticsTile = tester.widget<SwitchListTile>(diagnosticsSwitch);
expect(completionTile.onChanged, isNotNull);
expect(diagnosticsTile.onChanged, isNotNull);
expect(completionTile.value, isTrue);
expect(diagnosticsTile.value, isTrue);
});
testWidgets('代码补全管理页面支持英文多语言展示', (tester) async {
await tester.pumpWidget(buildTestWidget(locale: const Locale('en')));
await tester.pumpAndSettle();
expect(find.text('Backend Language Server'), findsOneWidget);
expect(find.text('Code Completion'), findsOneWidget);
expect(find.text('Code Correction'), findsOneWidget);
});
testWidgets('当总开关关闭时,两个分开关被禁用(onChanged == null)', (tester) async {
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
final masterSwitch = find.byKey(const ValueKey('lsp_master_switch'));
final completionSwitch = find.byKey(const ValueKey('code_completion_sub_switch'));
final diagnosticsSwitch = find.byKey(const ValueKey('code_diagnostics_sub_switch'));
// 点击总开关以关闭
await tester.tap(masterSwitch);
await tester.pumpAndSettle();
expect(settingsProvider.enableLspCompletion, isFalse);
// 验证总开关关闭后,两个分开关的 onChanged 为 null (禁用状态)
final disabledCompletionTile = tester.widget<SwitchListTile>(completionSwitch);
final disabledDiagnosticsTile = tester.widget<SwitchListTile>(diagnosticsSwitch);
expect(disabledCompletionTile.onChanged, isNull);
expect(disabledDiagnosticsTile.onChanged, isNull);
// 点击分开关不会发生任何状态变更
await tester.tap(completionSwitch);
await tester.pumpAndSettle();
expect(settingsProvider.enableCodeCompletion, isTrue);
// 重新开启总开关后,两个分开关重新恢复启用
await tester.tap(masterSwitch);
await tester.pumpAndSettle();
expect(settingsProvider.enableLspCompletion, isTrue);
final reenabledCompletionTile = tester.widget<SwitchListTile>(completionSwitch);
final reenabledDiagnosticsTile = tester.widget<SwitchListTile>(diagnosticsSwitch);
expect(reenabledCompletionTile.onChanged, isNotNull);
expect(reenabledDiagnosticsTile.onChanged, isNotNull);
});
testWidgets('总开关开启时,点击两个分开关可正常独立切换各自状态', (tester) async {
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
final completionSwitch = find.byKey(const ValueKey('code_completion_sub_switch'));
final diagnosticsSwitch = find.byKey(const ValueKey('code_diagnostics_sub_switch'));
// 切换代码补全分开关
await tester.tap(completionSwitch);
await tester.pumpAndSettle();
expect(settingsProvider.enableCodeCompletion, isFalse);
// 切换代码纠错分开关
await tester.tap(diagnosticsSwitch);
await tester.pumpAndSettle();
expect(settingsProvider.enableCodeDiagnostics, isFalse);
});
}
+24
View File
@@ -167,6 +167,30 @@ void main() {
expect(restoredProvider.enableLspCompletion, isFalse); expect(restoredProvider.enableLspCompletion, isFalse);
}); });
test('SettingsProvider sub-switches (code completion & diagnostics) default to true and persist', () async {
final provider = SettingsProvider();
await provider.init();
expect(provider.enableCodeCompletion, isTrue);
expect(provider.enableCodeDiagnostics, isTrue);
await provider.setEnableCodeCompletion(false);
await provider.setEnableCodeDiagnostics(false);
expect(provider.enableCodeCompletion, isFalse);
expect(provider.enableCodeDiagnostics, isFalse);
final prefs = await SharedPreferences.getInstance();
expect(prefs.getBool('enable_code_completion'), isFalse);
expect(prefs.getBool('enable_code_diagnostics'), isFalse);
// 重新实例化验证从持久化中正确恢复
final restoredProvider = SettingsProvider();
await restoredProvider.init();
expect(restoredProvider.enableCodeCompletion, isFalse);
expect(restoredProvider.enableCodeDiagnostics, isFalse);
});
test('SmartCodeAutocompletePromptsBuilder provider filtering by flag', () { test('SmartCodeAutocompletePromptsBuilder provider filtering by flag', () {
// 1. 默认开启:仅 1 个 LspCompletionProvider // 1. 默认开启:仅 1 个 LspCompletionProvider
final builderDefault = SmartCodeAutocompletePromptsBuilder(); final builderDefault = SmartCodeAutocompletePromptsBuilder();
+248
View File
@@ -0,0 +1,248 @@
import 'dart:io';
import 'package:code_editor/l10n/app_localizations.dart';
import 'package:code_editor/models/git_model.dart';
import 'package:code_editor/providers/git_provider.dart';
import 'package:code_editor/providers/settings_provider.dart';
import 'package:code_editor/providers/tab_provider.dart';
import 'package:code_editor/widgets/git/git_conflict_resolve_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path/path.dart' as p;
import 'package:provider/provider.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late Directory tempDir;
late File conflictFile;
late GitProvider gitProvider;
late TabProvider tabProvider;
late SettingsProvider settingsProvider;
const conflictContent = 'first line\n'
'<<<<<<< HEAD\n'
'current line 1\n'
'current line 2\n'
'=======\n'
'incoming line 1\n'
'>>>>>>> feature/test\n'
'last line\n';
setUp(() {
tempDir = Directory.systemTemp.createTempSync('git_conflict_test_');
conflictFile = File(p.join(tempDir.path, 'conflict_sample.txt'));
conflictFile.writeAsStringSync(conflictContent);
gitProvider = GitProvider();
tabProvider = TabProvider();
settingsProvider = SettingsProvider();
});
tearDown(() {
try {
tempDir.deleteSync(recursive: true);
} catch (_) {}
});
Widget buildTestWidget() {
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: gitProvider),
ChangeNotifierProvider.value(value: tabProvider),
ChangeNotifierProvider.value(value: settingsProvider),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('zh'),
home: GitConflictResolvePage(
file: GitConflictedFile(
relativePath: 'conflict_sample.txt',
absolutePath: conflictFile.path,
type: GitConflictType.bothModified,
),
gitProvider: gitProvider,
initialContent: conflictContent,
),
),
);
}
testWidgets('GitConflictResolvePage 成功渲染 VS Code 风格 CodeLens 与标头色带', (tester) async {
tester.view.physicalSize = const Size(1024, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
// 1. 验证文件名与未解决徽标
expect(find.text('conflict_sample.txt'), findsOneWidget);
expect(find.text('1 未解决'), findsOneWidget);
// 2. 验证 CodeLens 按钮(紧凑模式下自适应短文案)
expect(find.text('当前'), findsOneWidget);
expect(find.text('传入'), findsOneWidget);
expect(find.text('双方'), findsOneWidget);
expect(find.text('对比'), findsOneWidget);
// 3. 验证标头带与分隔线
expect(find.textContaining('<<<<<<< HEAD'), findsOneWidget);
expect(find.text('======='), findsOneWidget);
expect(find.textContaining('>>>>>>> feature/test'), findsOneWidget);
// 4. 验证底部按钮
expect(find.byKey(const ValueKey('git_conflict_edit_manually')), findsOneWidget);
expect(find.byKey(const ValueKey('git_conflict_save_and_mark')), findsOneWidget);
});
testWidgets('点击「对比查看」能够弹出差异比对弹窗', (tester) async {
tester.view.physicalSize = const Size(1024, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
// 点击对比查看
await tester.tap(find.text('对比'));
await tester.pumpAndSettle();
// 验证对比弹窗开启
expect(find.text('冲突对比 · 第 1 处'), findsOneWidget);
expect(find.textContaining('当前侧: HEAD'), findsOneWidget);
expect(find.textContaining('传入侧: feature/test'), findsOneWidget);
expect(find.text('取消'), findsOneWidget);
// 关闭弹窗
await tester.tap(find.text('取消'));
await tester.pumpAndSettle();
expect(find.text('冲突对比 · 第 1 处'), findsNothing);
});
testWidgets('点击「采用当前侧」正确替换该冲突块并更新状态为已解决', (tester) async {
tester.view.physicalSize = const Size(1024, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
// 点击采用当前侧并在真实异步环境中等待文件写入与状态更新
await tester.runAsync(() async {
await tester.tap(find.text('当前'));
await Future.delayed(const Duration(milliseconds: 200));
});
await tester.pumpAndSettle();
// 验证冲突标记消除,状态变为已全部解决
expect(find.text('已全部解决'), findsOneWidget);
expect(find.text('冲突已解决 · 保存并提交'), findsOneWidget);
// 验证磁盘文件内容确实被写入
final updatedContent = conflictFile.readAsStringSync();
expect(updatedContent.contains('<<<<<<<'), isFalse);
expect(updatedContent.contains('current line 1'), isTrue);
expect(updatedContent.contains('incoming line 1'), isFalse);
});
testWidgets('当遇到嵌套/畸形冲突标记时,页面展示「标记异常」徽标与警示横幅,且绝不误显「已全部解决」', (tester) async {
const malformedContent = '''
<<<<<<< HEAD
<<<<<<< ours
VERSION-A
=======
VERSION-B
>>>>>>> theirs
=======
VERSION-C
>>>>>>> 123456
''';
final malformedFile = File(p.join(tempDir.path, 'nested.txt'))..writeAsStringSync(malformedContent);
await tester.pumpWidget(
MultiProvider(
providers: [
ChangeNotifierProvider.value(value: gitProvider),
ChangeNotifierProvider.value(value: tabProvider),
ChangeNotifierProvider.value(value: settingsProvider),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('zh'),
home: GitConflictResolvePage(
file: GitConflictedFile(
relativePath: 'nested.txt',
absolutePath: malformedFile.path,
type: GitConflictType.bothModified,
),
gitProvider: gitProvider,
initialContent: malformedContent,
),
),
),
);
await tester.pumpAndSettle();
// 1. 验证顶栏展示「标记异常」,绝不显示「已全部解决」
expect(find.text('标记异常'), findsOneWidget);
expect(find.text('已全部解决'), findsNothing);
// 2. 验证页面顶部悬浮警告横幅
expect(find.textContaining('检测到冲突标记嵌套或不完整'), findsOneWidget);
// 3. 底栏不可显示「冲突已解决 · 保存并提交」
expect(find.text('冲突已解决 · 保存并提交'), findsNothing);
});
testWidgets('极窄屏幕(如 240px 宽度)下 CodeLens 操作栏不会触发 RenderFlex 溢出,且支持水平拖动交互', (tester) async {
tester.view.physicalSize = const Size(240, 600);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
// 确认没有 RenderFlex overflow 异常
expect(tester.takeException(), isNull);
// 验证 CodeLens 容器中的 SingleChildScrollView
final horizontalScrollView = find.byWidgetPredicate(
(widget) => widget is SingleChildScrollView && widget.scrollDirection == Axis.horizontal,
);
expect(horizontalScrollView, findsWidgets);
// 进行水平拖动手势滑动
await tester.drag(horizontalScrollView.first, const Offset(-100, 0));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
});
testWidgets('点击底栏「手动编辑」按钮能够正常触发并打开文件', (tester) async {
tester.view.physicalSize = const Size(1024, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(buildTestWidget());
await tester.pumpAndSettle();
final editBtn = find.byKey(const ValueKey('git_conflict_edit_manually'));
expect(editBtn, findsOneWidget);
await tester.tap(editBtn);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
});
}
+1 -1
View File
@@ -51,7 +51,7 @@ if ((Test-Path $patch) -and -not (Select-String -Path (Join-Path $SrcDir "shmem.
# --- app id(决定 _PATH_TMP:命名 shm key 的 symlink 存放位置)------------- # --- app id(决定 _PATH_TMP:命名 shm key 的 symlink 存放位置)-------------
if (-not $AppId) { if (-not $AppId) {
$m = Select-String -Path "android\app\build.gradle.kts" -Pattern 'applicationId\s*=\s*"([^"]+)"' | Select-Object -First 1 $m = Select-String -Path "android\app\build.gradle.kts" -Pattern 'applicationId\s*=\s*"([^"]+)"' | Select-Object -First 1
$AppId = if ($m) { $m.Matches.Groups[1].Value } else { "com.example.code_editor" } $AppId = if ($m) { $m.Matches.Groups[1].Value } else { "com.lzxnone.code_editor" }
} }
$tmpDef = "-D_PATH_TMP=`"/data/data/$AppId/cache/`"" $tmpDef = "-D_PATH_TMP=`"/data/data/$AppId/cache/`""
Write-Host "applicationId=$AppId _PATH_TMP=/data/data/$AppId/cache/" -ForegroundColor Cyan Write-Host "applicationId=$AppId _PATH_TMP=/data/data/$AppId/cache/" -ForegroundColor Cyan
+1 -1
View File
@@ -35,7 +35,7 @@ NDK=<ndk>/toolchains/llvm/prebuilt/<host>/bin
前提:app 为 **debug** 构建(`run-as` 需要),设备已连 adb。 前提:app 为 **debug** 构建(`run-as` 需要),设备已连 adb。
```bash ```bash
PKG=com.example.code_editor PKG=com.lzxnone.code_editor
BASE=/data/data/$PKG/files/distros/alpine BASE=/data/data/$PKG/files/distros/alpine
R=$BASE/rootfs R=$BASE/rootfs
+1 -1
View File
@@ -3,7 +3,7 @@
# 注意:这条路径经 run-as 启动,**没有** Android 的 app seccomp 过滤器 # 注意:这条路径经 run-as 启动,**没有** Android 的 app seccomp 过滤器
#(容器里看到的 Seccomp:2 是 proot 自己的加速过滤器)。因此涉及 #(容器里看到的 Seccomp:2 是 proot 自己的加速过滤器)。因此涉及
# poll/select 等平台策略的结论必须在 App 自己的会话里验证。 # poll/select 等平台策略的结论必须在 App 自己的会话里验证。
PKG=com.example.code_editor PKG=com.lzxnone.code_editor
BASE=/data/data/$PKG/files/distros/alpine BASE=/data/data/$PKG/files/distros/alpine
ROOT=$BASE/rootfs ROOT=$BASE/rootfs
# 按设备 ABI 选择(arm64-v8a / x86_64),避免写死导致换架构失效 # 按设备 ABI 选择(arm64-v8a / x86_64),避免写死导致换架构失效
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

+2 -2
View File
@@ -23,13 +23,13 @@
<!-- iOS meta tags & icons --> <!-- iOS meta tags & icons -->
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="code_editor"> <meta name="apple-mobile-web-app-title" content="LN 代码编辑器">
<link rel="apple-touch-icon" href="icons/Icon-192.png"> <link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/> <link rel="icon" type="image/png" href="favicon.png"/>
<title>code_editor</title> <title>LN 代码编辑器</title>
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
</head> </head>
<body> <body>
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "code_editor", "name": "LN 代码编辑器",
"short_name": "code_editor", "short_name": "LN 代码编辑器",
"start_url": ".", "start_url": ".",
"display": "standalone", "display": "standalone",
"background_color": "#0175C2", "background_color": "#0175C2",
Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 593 B