@@ -493,15 +493,20 @@ class FileExplorerController extends Notifier<FileExplorerState> {
493493 Future <void > openInEditor (String fileName) async {
494494 final String path = _join (state.cwd, fileName);
495495 final int epoch = ++ _openEpoch;
496- final EditorDocument before = ref.read (editorDocumentProvider);
496+ final int documentEpoch = ref.read (editorDocumentEpochProvider);
497+ final Connection connection = _conn;
498+ final Object stamp = connectionSessionStampOf (connection);
497499 try {
498- final Uint8List bytes = await _conn .getFile (
500+ final Uint8List bytes = await connection .getFile (
499501 path,
500502 onProgress: (TransferProgress progress) {
501503 if (epoch == _openEpoch) _onProgress (progress);
502504 },
503505 );
504- if (epoch != _openEpoch || ref.read (editorDocumentProvider) != before) {
506+ if (_disposed ||
507+ epoch != _openEpoch ||
508+ ref.read (editorDocumentEpochProvider) != documentEpoch ||
509+ ! _isCapturedSessionCurrent (connection: connection, stamp: stamp)) {
505510 return ;
506511 }
507512 state = state.copyWith (clearProgress: true );
@@ -562,14 +567,18 @@ class FileExplorerController extends Notifier<FileExplorerState> {
562567 Future <void > uploadCurrentBuffer () async {
563568 final EditorDocument doc = ref.read (editorDocumentProvider);
564569 final String path = _join (state.cwd, doc.name);
570+ final int epoch = ref.read (editorDocumentEpochProvider);
571+ final Connection connection = _conn;
572+ final Object stamp = connectionSessionStampOf (connection);
565573 try {
566- await _conn .putFile (
574+ await connection .putFile (
567575 path,
568576 Uint8List .fromList (utf8.encode (doc.content)),
569577 onProgress: _onProgress,
570578 );
571579 state = state.copyWith (clearProgress: true );
572- if (ref.read (editorDocumentProvider) == doc) {
580+ if (ref.read (editorDocumentEpochProvider) == epoch &&
581+ _isCapturedSessionCurrent (connection: connection, stamp: stamp)) {
573582 ref.read (editorDocumentProvider.notifier).markSaved (boardPath: path);
574583 }
575584 await refresh ();
0 commit comments