Skip to content

Commit 554da56

Browse files
committed
refactor: extract file change processing into a separate method and apply it on the both modes: "usual" and forced
1 parent a64cd80 commit 554da56

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

MainWindow.xaml.cs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -972,22 +972,28 @@ private void OnSingleFileChanged(object sender, FileSystemEventArgs e)
972972
// Update the file status in the status bar
973973
UpdateFileStatus();
974974

975-
// Process all enabled tabs in parallel for better performance
976-
ProcessAllEnabledTabsParallel();
977-
978-
// Mark files as changed for disabled tabs
979-
foreach (var tab in tabs.Where(t => !t.IsWatchingEnabled))
980-
{
981-
if (tab.TabItem.IsSelected == false)
982-
{
983-
// Set the file changed flag for disabled non active tabs
984-
tab.FileChangedFlag = true;
985-
}
986-
}
975+
// Process changes in the file
976+
ProcessChanges();
987977
});
988978
}
989979
}
990980

981+
private void ProcessChanges()
982+
{
983+
// Process all enabled tabs in parallel for better performance
984+
ProcessAllEnabledTabsParallel();
985+
986+
// Mark files as changed for disabled tabs
987+
foreach (var tab in tabs.Where(t => !t.IsWatchingEnabled))
988+
{
989+
if (tab.TabItem.IsSelected == false)
990+
{
991+
// Set the file changed flag for disabled non active tabs
992+
tab.FileChangedFlag = true;
993+
}
994+
}
995+
}
996+
991997
/// <summary>
992998
/// Processes file updates in parallel for all enabled tabs by reading each source line once
993999
/// and applying it to all tabs that match the line.
@@ -1495,20 +1501,8 @@ private void OnForcedRefreshTimerTick(object? sender, EventArgs e)
14951501
// Simulate the file change event
14961502
Dispatcher.Invoke(() =>
14971503
{
1498-
// Process each tab based on its watching state
1499-
foreach (var tab in tabs)
1500-
{
1501-
if (tab.IsWatchingEnabled)
1502-
{
1503-
// If watching is enabled, process the content now
1504-
ProcessTabContent(tab);
1505-
}
1506-
else
1507-
{
1508-
// If watching is disabled, just mark the file changed flag
1509-
tab.FileChangedFlag = true;
1510-
}
1511-
}
1504+
// Process changes as if the file was modified
1505+
ProcessChanges();
15121506
});
15131507
}
15141508
}

0 commit comments

Comments
 (0)