fix crashes with curly braces

This commit is contained in:
haven1433 2025-12-01 06:55:08 -06:00
parent ab6e688208
commit bab9ff3586
2 changed files with 3 additions and 3 deletions

View File

@ -448,7 +448,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
break;
}
if (close == -1) {
if (i == caret) {
if (i == caret || (i == caret - 1 && caret == text.Count)) {
text.Insert(i + 1, '\r');
text.Insert(i + 2, '\n');
}
@ -827,7 +827,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
partialDocumentation = candidates[0].Usage + Environment.NewLine + string.Join(Environment.NewLine, candidates[0].Documentation);
}
if (context.Index > 0 && context.Line[context.Index - 1] == ' ' && tokens.Length > 0) {
if (context.Index > 0 && context.Index < context.Line.Length && context.Line[context.Index - 1] == ' ' && tokens.Length > 0) {
// I'm directly after a space, I'm at the start of a new token, there is no existing documentation
var skipCount = candidates[0].LineCode.Count;
if (skipCount == 0) skipCount = 1;

View File

@ -463,7 +463,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools {
if (lines[i].Trim() == "{") {
var type = queue.Count == 0 ? ExpectedPointerType.Unknown : queue.Dequeue();
i += 1;
while (lines[i].Trim() != "}") {
while (i < lines.Length && lines[i].Trim() != "}") {
results.Add(new(i, type, lines[i]));
i += 1;
if (lines.Length <= i) break;