From 9865c776f5a0b10855fc8899a90c39d2b0e51e6d Mon Sep 17 00:00:00 2001 From: Emil Halvarsson Date: Wed, 31 Dec 2025 00:22:53 +0100 Subject: [PATCH 1/2] Fix syntax highlighting when changing height of Terminal --- EditorContext/EditorContext.cs | 1 + EditorContext/JSONEditorContext.cs | 3 ++- EditorContext/MarkdownEditorContext.cs | 3 ++- EditorContext/PowerShellEditorContext.cs | 3 ++- EditorContext/XmlEditorContext.cs | 3 ++- EditorContext/YamlEditorContext.cs | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/EditorContext/EditorContext.cs b/EditorContext/EditorContext.cs index 7d50e7d..dc5705d 100644 --- a/EditorContext/EditorContext.cs +++ b/EditorContext/EditorContext.cs @@ -9,6 +9,7 @@ public abstract class EditorContext { public string _originalText; public int _lastParseTopRow; + public int _lastParseHeight; public int _lastParseRightColumn; public int _tabWidth; public bool CanFormat = false; diff --git a/EditorContext/JSONEditorContext.cs b/EditorContext/JSONEditorContext.cs index a89bbef..5fd19e8 100644 --- a/EditorContext/JSONEditorContext.cs +++ b/EditorContext/JSONEditorContext.cs @@ -126,7 +126,7 @@ public List ParseJsonToken(string text, List> Runes) public override void ParseText(int height, int topRow, int left, int right, string text, List> Runes) { // quick exit when text is the same and the top row / right col has not changed - if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn) + if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && height == _lastParseHeight) { return; } @@ -144,6 +144,7 @@ public override void ParseText(int height, int topRow, int left, int right, stri int bottom = topRow + height; _originalText = text; _lastParseTopRow = topRow; + _lastParseHeight = height; _lastParseRightColumn = right; long count = 0; var row = 0; diff --git a/EditorContext/MarkdownEditorContext.cs b/EditorContext/MarkdownEditorContext.cs index 2ac2267..9b1ef84 100644 --- a/EditorContext/MarkdownEditorContext.cs +++ b/EditorContext/MarkdownEditorContext.cs @@ -184,7 +184,7 @@ public List ParseMarkdownToken(string text, List> Runes) public override void ParseText(int height, int topRow, int left, int right, string text, List> Runes) { // Quick exit when text is the same and the top row / right col has not changed - if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn) + if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && _lastParseHeight == height) { return; } @@ -202,6 +202,7 @@ public override void ParseText(int height, int topRow, int left, int right, stri int bottom = topRow + height; _originalText = text; _lastParseTopRow = topRow; + _lastParseHeight = height; _lastParseRightColumn = right; var row = 0; diff --git a/EditorContext/PowerShellEditorContext.cs b/EditorContext/PowerShellEditorContext.cs index cd9e3e9..9cab8a3 100644 --- a/EditorContext/PowerShellEditorContext.cs +++ b/EditorContext/PowerShellEditorContext.cs @@ -197,7 +197,7 @@ public List ParsePowershellToken(Token[] tokens, string text, List< public override void ParseText(int height, int topRow, int left, int right, string text, List> Runes) { // quick exit when text is the same and the top row / right col has not changed - if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn) + if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && _lastParseHeight == height) { return; } @@ -217,6 +217,7 @@ public override void ParseText(int height, int topRow, int left, int right, stri int bottom = topRow + height; _originalText = text; _lastParseTopRow = topRow; + _lastParseHeight = height; _lastParseRightColumn = right; var row = 0; for (int idxRow = topRow; idxRow < Runes.Count; idxRow++) diff --git a/EditorContext/XmlEditorContext.cs b/EditorContext/XmlEditorContext.cs index 6df2832..16f05bc 100644 --- a/EditorContext/XmlEditorContext.cs +++ b/EditorContext/XmlEditorContext.cs @@ -391,7 +391,7 @@ private void AddParseResult(List resultList, int lineNumber, int st public override void ParseText(int height, int topRow, int left, int right, string text, List> Runes) { - if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn) + if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && _lastParseHeight == height) { return; } @@ -408,6 +408,7 @@ public override void ParseText(int height, int topRow, int left, int right, stri int bottom = topRow + height; _originalText = text; _lastParseTopRow = topRow; + _lastParseHeight = height; _lastParseRightColumn = right; var row = 0; diff --git a/EditorContext/YamlEditorContext.cs b/EditorContext/YamlEditorContext.cs index 0996d93..50ffb4a 100644 --- a/EditorContext/YamlEditorContext.cs +++ b/EditorContext/YamlEditorContext.cs @@ -115,7 +115,7 @@ public List ParseYamlToken(string text, List> Runes) } public override void ParseText(int height, int topRow, int left, int right, string text, List> Runes) { - if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn) + if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && _lastParseHeight == height) { return; } @@ -130,6 +130,7 @@ public override void ParseText(int height, int topRow, int left, int right, stri int bottom = topRow + height; _originalText = text; _lastParseTopRow = topRow; + _lastParseHeight = height; _lastParseRightColumn = right; long count = 0; var row = 0; From 3f5296644287abd5ee5dab7288673609beb6b544 Mon Sep 17 00:00:00 2001 From: Emil Halvarsson Date: Wed, 31 Dec 2025 00:25:03 +0100 Subject: [PATCH 2/2] align quick exit condition with other contexts --- EditorContext/JSONEditorContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EditorContext/JSONEditorContext.cs b/EditorContext/JSONEditorContext.cs index 5fd19e8..151ebd1 100644 --- a/EditorContext/JSONEditorContext.cs +++ b/EditorContext/JSONEditorContext.cs @@ -126,7 +126,7 @@ public List ParseJsonToken(string text, List> Runes) public override void ParseText(int height, int topRow, int left, int right, string text, List> Runes) { // quick exit when text is the same and the top row / right col has not changed - if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && height == _lastParseHeight) + if (_originalText == text && topRow == _lastParseTopRow && right == _lastParseRightColumn && _lastParseHeight == height) { return; }