From 1c5306b7c81ff732523b0aeffc88143e0496db6e Mon Sep 17 00:00:00 2001 From: Sinai Date: Mon, 3 May 2021 00:59:39 +1000 Subject: [PATCH] Fix the onValueChange throttling affecting internal features --- src/ExplorerCore.cs | 2 +- src/UI/Main/CSConsole/CSharpConsole.cs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 6683e83..ee2d8d3 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -14,7 +14,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.3.14"; + public const string VERSION = "3.3.15"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/UI/Main/CSConsole/CSharpConsole.cs b/src/UI/Main/CSConsole/CSharpConsole.cs index c495f57..43d66a0 100644 --- a/src/UI/Main/CSConsole/CSharpConsole.cs +++ b/src/UI/Main/CSConsole/CSharpConsole.cs @@ -201,6 +201,8 @@ The following helper methods are available: public void UpdateConsole() { + if (Time.time > s_timeOfLastInternalSet) + Writing = false; if (EnableCtrlRShortcut) { @@ -259,6 +261,8 @@ The following helper methods are available: public void UseAutocomplete(string suggestion) { + Writing = true; + string input = InputField.text; input = input.Insert(m_lastCaretPos, suggestion); InputField.text = input; @@ -274,10 +278,22 @@ The following helper methods are available: } private static float s_timeOfLastUpdate; + private static bool Writing + { + get => s_writing; + set + { + if (value) + s_timeOfLastInternalSet = Time.time; + s_writing = value; + } + } + private static bool s_writing; + private static float s_timeOfLastInternalSet; public void OnInputChanged(string newText, bool forceUpdate = false) { - if (Time.time <= s_timeOfLastUpdate) + if (!Writing && Time.time <= s_timeOfLastUpdate) return; s_timeOfLastUpdate = Time.time; @@ -285,6 +301,8 @@ The following helper methods are available: if (EnableAutoIndent) UpdateIndent(newText); + Writing = true; + if (!forceUpdate && string.IsNullOrEmpty(newText)) inputHighlightText.text = string.Empty; else @@ -361,6 +379,8 @@ The following helper methods are available: private void AutoIndentCaret() { + Writing = true; + if (CurrentIndent > 0) { string indent = GetAutoIndentTab(CurrentIndent);