mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
optimize<TextEditor>: trait all .h file as C++ header file instead of C
This commit is contained in:
parent
b934049dba
commit
ba355a7d59
3 changed files with 55 additions and 20 deletions
|
@ -214,10 +214,7 @@ namespace SourceGit.Views {
|
|||
}
|
||||
|
||||
_textMate = this.InstallTextMate(_registryOptions);
|
||||
|
||||
if (DiffData != null) {
|
||||
_textMate.SetGrammar(_registryOptions.GetScopeByExtension(Path.GetExtension(DiffData.File)));
|
||||
}
|
||||
UpdateGrammar();
|
||||
}
|
||||
|
||||
protected override void OnUnloaded(RoutedEventArgs e) {
|
||||
|
@ -267,7 +264,7 @@ namespace SourceGit.Views {
|
|||
builder.AppendLine(line.Content);
|
||||
}
|
||||
|
||||
if (_textMate != null) _textMate.SetGrammar(_registryOptions.GetScopeByExtension(Path.GetExtension(DiffData.File)));
|
||||
UpdateGrammar();
|
||||
Text = builder.ToString();
|
||||
} else {
|
||||
Text = string.Empty;
|
||||
|
@ -281,6 +278,17 @@ namespace SourceGit.Views {
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateGrammar() {
|
||||
if (_textMate == null || DiffData == null) return;
|
||||
|
||||
var ext = Path.GetExtension(DiffData.File);
|
||||
if (ext == ".h") {
|
||||
_textMate.SetGrammar(_registryOptions.GetScopeByLanguageId("cpp"));
|
||||
} else {
|
||||
_textMate.SetGrammar(_registryOptions.GetScopeByExtension(ext));
|
||||
}
|
||||
}
|
||||
|
||||
private RegistryOptions _registryOptions;
|
||||
private TextMate.Installation _textMate;
|
||||
}
|
||||
|
@ -497,10 +505,7 @@ namespace SourceGit.Views {
|
|||
}
|
||||
|
||||
_textMate = this.InstallTextMate(_registryOptions);
|
||||
|
||||
if (DiffData != null) {
|
||||
_textMate.SetGrammar(_registryOptions.GetScopeByExtension(Path.GetExtension(DiffData.File)));
|
||||
}
|
||||
UpdateGrammar();
|
||||
}
|
||||
|
||||
protected override void OnUnloaded(RoutedEventArgs e) {
|
||||
|
@ -561,7 +566,7 @@ namespace SourceGit.Views {
|
|||
}
|
||||
}
|
||||
|
||||
if (_textMate != null) _textMate.SetGrammar(_registryOptions.GetScopeByExtension(Path.GetExtension(DiffData.File)));
|
||||
UpdateGrammar();
|
||||
Text = builder.ToString();
|
||||
} else {
|
||||
Text = string.Empty;
|
||||
|
@ -580,6 +585,17 @@ namespace SourceGit.Views {
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateGrammar() {
|
||||
if (_textMate == null || DiffData == null) return;
|
||||
|
||||
var ext = Path.GetExtension(DiffData.File);
|
||||
if (ext == ".h") {
|
||||
_textMate.SetGrammar(_registryOptions.GetScopeByLanguageId("cpp"));
|
||||
} else {
|
||||
_textMate.SetGrammar(_registryOptions.GetScopeByExtension(ext));
|
||||
}
|
||||
}
|
||||
|
||||
private RegistryOptions _registryOptions;
|
||||
private TextMate.Installation _textMate;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue