optimize: collect garbage after SetGrammar to avoid memory leak

This commit is contained in:
leo 2024-03-20 19:49:01 +08:00
parent 340fe9e3ba
commit 8fc25e312d
3 changed files with 6 additions and 4 deletions

View file

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using Avalonia.Styling;
@ -54,6 +55,7 @@ namespace SourceGit.Models
var reg = installation.RegistryOptions as RegistryOptions;
installation.SetGrammar(reg.GetScopeByExtension(ext));
GC.Collect();
}
}
}

View file

@ -64,8 +64,8 @@ namespace SourceGit.Views
var source = DataContext as Models.RevisionTextFile;
if (source != null)
{
Models.TextMateHelper.SetGrammarByFileName(_textMate, source.FileName);
Text = source.Content;
Models.TextMateHelper.SetGrammarByFileName(_textMate, source.FileName);
}
}

View file

@ -317,8 +317,8 @@ namespace SourceGit.Views
builder.AppendLine(line.Content);
}
Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File);
Text = builder.ToString();
Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File);
}
else
{
@ -675,8 +675,8 @@ namespace SourceGit.Views
}
}
Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File);
Text = builder.ToString();
Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File);
}
else
{