diff --git a/win_text_editor/lib/app/widgets/text_tab.dart b/win_text_editor/lib/app/widgets/text_tab.dart index 5a80a26..c810097 100644 --- a/win_text_editor/lib/app/widgets/text_tab.dart +++ b/win_text_editor/lib/app/widgets/text_tab.dart @@ -121,7 +121,7 @@ class _TextTabState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '源文本${tab.content.isEmpty ? '' : ' (${tab.content.length}字符)'}', + '源文本${tab.content.isEmpty ? '' : ' (${tab.fileName!.isEmpty ? '' : '${tab.fileName},'}${tab.content.length}字符)'}', style: const TextStyle(fontWeight: FontWeight.bold), ), Row( @@ -196,7 +196,7 @@ class _TextTabState extends State { focusNode: _focusNode, maxLines: null, scrollController: _scrollController, // 使用同一个滚动控制器 - onChanged: (text) => _provider.updateContent(widget.tabId, text), + onChanged: (text) => _provider.updateContent(widget.tabId, text, tab.fileName), decoration: const InputDecoration( border: InputBorder.none, contentPadding: EdgeInsets.all(16), @@ -226,7 +226,7 @@ class _TextTabState extends State { final file = File(result.files.single.path!); final content = await file.readAsString(); - _provider.updateContent(widget.tabId, content); + _provider.updateContent(widget.tabId, content, result.files.first.name); setState(() { _controller.text = content; _detectLanguage();