partially fix highlighting flash on external set
This commit is contained in:
@@ -42,6 +42,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
private ImmutableArray<SharpIdeDiagnostic> _projectDiagnosticsForFile = [];
|
private ImmutableArray<SharpIdeDiagnostic> _projectDiagnosticsForFile = [];
|
||||||
private ImmutableArray<CodeAction> _currentCodeActionsInPopup = [];
|
private ImmutableArray<CodeAction> _currentCodeActionsInPopup = [];
|
||||||
private bool _fileChangingSuppressBreakpointToggleEvent;
|
private bool _fileChangingSuppressBreakpointToggleEvent;
|
||||||
|
private bool _settingWholeDocumentTextSuppressLineEditsEvent; // A dodgy workaround - setting the whole document doesn't guarantee that the line count stayed the same etc. We are still going to have broken highlighting. TODO: Investigate getting minimal text change ranges, and change those ranges only
|
||||||
|
|
||||||
[Inject] private readonly IdeOpenTabsFileManager _openTabsFileManager = null!;
|
[Inject] private readonly IdeOpenTabsFileManager _openTabsFileManager = null!;
|
||||||
[Inject] private readonly RunService _runService = null!;
|
[Inject] private readonly RunService _runService = null!;
|
||||||
@@ -99,6 +100,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
private void OnLinesEditedFrom(long fromLine, long toLine)
|
private void OnLinesEditedFrom(long fromLine, long toLine)
|
||||||
{
|
{
|
||||||
if (fromLine == toLine) return;
|
if (fromLine == toLine) return;
|
||||||
|
if (_settingWholeDocumentTextSuppressLineEditsEvent) return;
|
||||||
var fromLineText = GetLine((int)fromLine);
|
var fromLineText = GetLine((int)fromLine);
|
||||||
var caretPosition = this.GetCaretPosition();
|
var caretPosition = this.GetCaretPosition();
|
||||||
var textFrom0ToCaret = fromLineText[..caretPosition.col];
|
var textFrom0ToCaret = fromLineText[..caretPosition.col];
|
||||||
@@ -304,17 +306,19 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
private async Task OnFileChangedExternally(SharpIdeFileLinePosition? linePosition)
|
private async Task OnFileChangedExternally(SharpIdeFileLinePosition? linePosition)
|
||||||
{
|
{
|
||||||
var fileContents = await _openTabsFileManager.GetFileTextAsync(_currentFile);
|
var fileContents = await _openTabsFileManager.GetFileTextAsync(_currentFile);
|
||||||
Callable.From(() =>
|
await this.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
(int line, int col) currentCaretPosition = linePosition is null ? GetCaretPosition() : (linePosition.Value.Line, linePosition.Value.Column);
|
(int line, int col) currentCaretPosition = linePosition is null ? GetCaretPosition() : (linePosition.Value.Line, linePosition.Value.Column);
|
||||||
var vScroll = GetVScroll();
|
var vScroll = GetVScroll();
|
||||||
BeginComplexOperation();
|
BeginComplexOperation();
|
||||||
|
_settingWholeDocumentTextSuppressLineEditsEvent = true;
|
||||||
SetText(fileContents);
|
SetText(fileContents);
|
||||||
|
_settingWholeDocumentTextSuppressLineEditsEvent = false;
|
||||||
SetCaretLine(currentCaretPosition.line);
|
SetCaretLine(currentCaretPosition.line);
|
||||||
SetCaretColumn(currentCaretPosition.col);
|
SetCaretColumn(currentCaretPosition.col);
|
||||||
SetVScroll(vScroll);
|
SetVScroll(vScroll);
|
||||||
EndComplexOperation();
|
EndComplexOperation();
|
||||||
}).CallDeferred();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFileLinePosition(SharpIdeFileLinePosition fileLinePosition)
|
public void SetFileLinePosition(SharpIdeFileLinePosition fileLinePosition)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
using Godot;
|
using Godot;
|
||||||
using SharpIDE.Application.Features.Analysis;
|
using SharpIDE.Application.Features.Analysis;
|
||||||
using SharpIDE.Application.Features.Build;
|
using SharpIDE.Application.Features.Build;
|
||||||
@@ -91,7 +92,10 @@ public partial class IdeRoot : Control
|
|||||||
// TODO: Problematic, as this is called even when the focus shifts to an embedded subwindow, such as a popup
|
// TODO: Problematic, as this is called even when the focus shifts to an embedded subwindow, such as a popup
|
||||||
private void OnFocusExited()
|
private void OnFocusExited()
|
||||||
{
|
{
|
||||||
_ = Task.GodotRun(async () => await _openTabsFileManager.SaveAllOpenFilesAsync());
|
if (Debugger.IsAttached is false)
|
||||||
|
{
|
||||||
|
_ = Task.GodotRun(async () => await _openTabsFileManager.SaveAllOpenFilesAsync());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRunMenuButtonPressed()
|
private void OnRunMenuButtonPressed()
|
||||||
|
|||||||
Reference in New Issue
Block a user