Skip to content

Commit f2558ea

Browse files
author
Juan Segura
committed
Autocomplete bug fixed
1 parent 52b1e1c commit f2558ea

File tree

10 files changed

+65
-48
lines changed

10 files changed

+65
-48
lines changed

Bufdio/Bufdio.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="FFmpeg.AutoGen" Version="5.1.1" />
12+
<PackageReference Include="FFmpeg.AutoGen" Version="6.1.0.1" />
1313
</ItemGroup>
1414

1515
</Project>

MsBox.Avalonia/AttachadProperty/HyperLinkCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System.Reactive;
21
using System.Windows.Input;
32
using Avalonia;
43
using Avalonia.Data;
54
using Avalonia.Input;
65
using Avalonia.Interactivity;
6+
using Avalonia.Reactive;
77

88
namespace MsBox.Avalonia.AttachadProperty;
99

MsBox.Avalonia/MsBox.Avalonia.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<AvaloniaResource Include="Assets\*" />
2727
</ItemGroup>
2828
<ItemGroup>
29-
<PackageReference Include="Avalonia" Version="11.1.3" />
29+
<PackageReference Include="Avalonia" Version="11.2.3" />
3030
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.1.0" />
31-
<PackageReference Include="DialogHost.Avalonia" Version="0.7.9" />
31+
<PackageReference Include="DialogHost.Avalonia" Version="0.9.2" />
3232
<PackageReference Include="Markdown.Avalonia.Tight" Version="11.0.2" />
3333
</ItemGroup>
3434
<ItemGroup>

ZXBStudio/DocumentEditors/ZXGraphics/log/ExportManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Generic;
55
using System.IO;
66
using System.Linq;
7-
using System.Reactive.Joins;
87
using System.Text;
98
using System.Threading.Tasks;
109
using ZXBasicStudio.BuildSystem;

ZXBStudio/DocumentEditors/ZXTextEditor/Classes/LanguageDefinitions/ZXBasicCompletionData.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public ZXBasicCompletionData(ZXBasicCompletionType DataType, string Text, string
5555

5656
public string Text { get; }
5757

58-
public object Content => Text;
58+
public object Content => this; // Text;
5959

6060
public object Description { get; }
6161

@@ -66,8 +66,11 @@ public void Complete(TextArea textArea, ISegment completionSegment,
6666
{
6767
textArea.Document.Replace(completionSegment, Text);
6868
}
69+
70+
public override string ToString() => Text;
6971
}
7072

73+
7174
public enum ZXBasicCompletionType
7275
{
7376
Keyword,

ZXBStudio/DocumentEditors/ZXTextEditor/Controls/ZXBasicEditor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,10 @@ public ZXBasicEditor(string DocumentPath) : base(DocumentPath, ZXBasicDocument.I
487487

488488
if (!ByRequest)
489489
{
490-
if(ZXOptions.Current.DisableAuto)
490+
if (ZXOptions.Current.DisableAuto)
491+
{
491492
return null;
493+
}
492494
}
493495

494496
if (ByRequest)
@@ -540,7 +542,8 @@ public ZXBasicEditor(string DocumentPath) : base(DocumentPath, ZXBasicDocument.I
540542
}
541543

542544

543-
if (string.IsNullOrWhiteSpace(preText))
545+
//if (string.IsNullOrWhiteSpace(preText))
546+
if(trimmed.Length > 1)
544547
{
545548
if (RequestedChar == '#')
546549
return directives;

ZXBStudio/DocumentEditors/ZXTextEditor/Controls/ZXTextEditor.axaml.cs

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
using AvaloniaEdit.Utils;
3636
using static System.Runtime.InteropServices.JavaScript.JSType;
3737
using System.Diagnostics;
38+
using SixLabors.ImageSharp.Formats.Webp;
3839

3940
namespace ZXBasicStudio.DocumentEditors.ZXTextEditor.Controls
4041
{
@@ -99,14 +100,14 @@ public partial class ZXTextEditor : ZXDocumentEditorBase, IObserver<AvaloniaProp
99100
public override string DocumentName => _docName;
100101
public override string DocumentPath => _docPath;
101102
public override bool Modified
102-
{
103-
get
104-
{
105-
if (_docPath == ZXConstants.DISASSEMBLY_DOC || _docPath == ZXConstants.ROM_DOC)
106-
return false;
107-
108-
return editor?.IsModified ?? false;
109-
}
103+
{
104+
get
105+
{
106+
if (_docPath == ZXConstants.DISASSEMBLY_DOC || _docPath == ZXConstants.ROM_DOC)
107+
return false;
108+
109+
return editor?.IsModified ?? false;
110+
}
110111
}
111112
#endregion
112113

@@ -139,15 +140,15 @@ public int? BreakLine
139140
#region Constructors
140141
public ZXTextEditor() : this("Untitled", ZXTextDocument.Id)
141142
{
142-
143+
143144
}
144145
public ZXTextEditor(string DocumentPath, Guid DocumentTypeId)
145146
{
146147
InitializeComponent();
147148

148149
_docTypeId = DocumentTypeId;
149150
InitializeShortcuts();
150-
151+
151152
editor.DataContext = editor;
152153
editor.FontSize = ZXOptions.Current.EditorFontSize;
153154
editor.WordWrap = ZXOptions.Current.WordWrap;
@@ -208,19 +209,25 @@ private void TextArea_TextEntering(object? sender, TextInputEventArgs e)
208209
{
209210

210211
if (e.Text == null || e.Text.Length == 0)
212+
{
211213
return;
214+
}
212215

213216
if (completionWindow == null && !string.IsNullOrWhiteSpace(e.Text) && !char.IsNumber(e.Text[0]))
214217
{
215218
var d = (IDocument)editor.Document;
216219
var completionData = ShouldComplete(editor.Document, editor.TextArea.Caret.Line, editor.TextArea.Caret.Column - 1, e.Text[0], false);
217220

218221
if (completionData != null)
222+
{
219223
ShowCompletion(completionData, false);
224+
}
220225
}
221226
else if (completionWindow != null && !char.IsLetterOrDigit(e.Text[0]))
227+
{
222228
completionWindow.CompletionList.RequestInsertion(e);
223-
229+
}
230+
224231
}
225232

226233
private void TextArea_KeyDown(object? sender, KeyEventArgs e)
@@ -231,7 +238,9 @@ private void TextArea_KeyDown(object? sender, KeyEventArgs e)
231238
var completionData = ShouldComplete(editor.Document, editor.TextArea.Caret.Line, editor.TextArea.Caret.Column - 1, null, true);
232239

233240
if (completionData != null)
241+
{
234242
ShowCompletion(completionData, true);
243+
}
235244
}
236245
}
237246

@@ -240,10 +249,9 @@ private void ShowCompletion(IEnumerable<ICompletionData> completions, bool reque
240249
if (completionWindow == null)
241250
{
242251
completionWindow = new CompletionWindow(editor.TextArea);
243-
244252
ICompletionData? selectedItem = null;
245253

246-
if (requested)
254+
//if (requested)
247255
{
248256
var line = editor.Document.GetLineByNumber(editor.TextArea.Caret.Line);
249257
var text = editor.Document.GetText(line);
@@ -270,6 +278,7 @@ private void ShowCompletion(IEnumerable<ICompletionData> completions, bool reque
270278
data.AddRange(completions);
271279
completionWindow.Show();
272280
completionWindow.CompletionList.SelectedItem = selectedItem;
281+
273282
completionWindow.KeyDown += (s, e) =>
274283
{
275284
if (e.Key == Key.F1 && completionWindow.CompletionList.SelectedItem != null)
@@ -512,20 +521,20 @@ public override bool SaveDocument(TextWriter OutputLog)
512521

513522
return true;
514523
}
515-
catch(Exception ex)
524+
catch (Exception ex)
516525
{
517526
OutputLog.WriteLine($"Error saving file {_docPath}: {ex.Message}");
518527
return false;
519528
}
520529
}
521530
public override bool RenameDocument(string NewName, TextWriter OutputLog)
522531
{
523-
try
532+
try
524533
{
525534
UpdateFileName(_docPath, NewName);
526535
return true;
527536
}
528-
catch(Exception ex)
537+
catch (Exception ex)
529538
{
530539
OutputLog.WriteLine($"Error internally updating the document name: {ex.Message}");
531540
return false;
@@ -602,22 +611,22 @@ public void Expand()
602611
foreach (var fold in fManager.AllFoldings)
603612
fold.IsFolded = false;
604613
}
605-
614+
606615
public void FontIncrease()
607616
{
608617
editor.FontSize++;
609618
}
610-
619+
611620
public void FontDecrease()
612621
{
613622
editor.FontSize--;
614623
}
615-
624+
616625
public void CommentSelection()
617626
{
618627
if (editor.IsReadOnly || commentChar == null || editor.TextArea.Selection == null)
619628
return;
620-
629+
621630
TextDocument document = editor.TextArea.Document;
622631

623632
if (editor.TextArea.Selection.Length == 0)
@@ -629,7 +638,7 @@ public void CommentSelection()
629638
else
630639
{
631640
IEnumerable<SelectionSegment> selectionSegments = editor.TextArea.Selection.Segments;
632-
641+
633642
foreach (SelectionSegment segment in selectionSegments)
634643
{
635644
int lineStart = document.GetLineByOffset(segment.StartOffset).LineNumber;
@@ -741,17 +750,17 @@ private void Document_Changing(object? sender, DocumentChangeEventArgs e)
741750

742751
if (e.RemovalLength > 0)
743752
{
744-
753+
745754
int end = start + e.RemovalLength;
746755
int linesRemoved = 0;
747756
int pos = start;
748-
while(pos < end)
757+
while (pos < end)
749758
{
750759
var line = editor.Document.GetLineByOffset(pos);
751760
if (pos >= line.EndOffset)
752761
firstLine++;
753762

754-
763+
755764
string lineText = editor.Document.GetText(line.Offset, line.Length);
756765
int removalLength = Math.Min(line.EndOffset - pos, end - pos);
757766
string leftText = lineText.Remove(pos - line.Offset, removalLength);
@@ -766,11 +775,11 @@ private void Document_Changing(object? sender, DocumentChangeEventArgs e)
766775
linesRemoved++;
767776
}
768777

769-
if(linesRemoved > 0)
778+
if (linesRemoved > 0)
770779
changed |= MoveBreakpoints(firstLine, -linesRemoved);
771780
}
772781

773-
if(changed)
782+
if (changed)
774783
bpMargin?.InvalidateVisual();
775784
}
776785
private void Document_Changed(object? sender, DocumentChangeEventArgs e)
@@ -801,7 +810,7 @@ private void Document_Changed(object? sender, DocumentChangeEventArgs e)
801810

802811
var firstText = editor.Document.GetText(firstLine.Offset, firstLine.Length);
803812

804-
if(!string.IsNullOrWhiteSpace(firstText))
813+
if (!string.IsNullOrWhiteSpace(firstText))
805814
changed = MoveBreakpoints(firstLine.LineNumber + 1, addedLines);
806815
else
807816
changed = MoveBreakpoints(firstLine.LineNumber, addedLines);
@@ -873,12 +882,12 @@ public void UpdateFontSize(bool increase)
873882
#region IObserver implementation for modified document notifications
874883
public void OnCompleted()
875884
{
876-
885+
877886
}
878887

879888
public void OnError(Exception error)
880889
{
881-
890+
882891
}
883892

884893
public void OnNext(AvaloniaPropertyChangedEventArgs value)

ZXBStudio/MainWindow.axaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ public MainWindow()
215215
regView.Registers = emu.Registers;
216216
memView.Initialize(emu.Memory);
217217
CreateRomBreakpoints();
218+
#if DEBUG
219+
this.AttachDevTools();
220+
#endif
218221
#endregion
219222

220223
#region Player intialization

ZXBStudio/ZXBasicStudio.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,17 @@
536536
</ItemGroup>
537537

538538
<ItemGroup>
539-
<PackageReference Include="Avalonia" Version="11.1.3" />
539+
<PackageReference Include="Avalonia" Version="11.2.3" />
540540
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.1.0" />
541-
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
542-
<PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0" />
543-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.3" />
541+
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
542+
<PackageReference Include="Avalonia.Svg.Skia" Version="11.2.0.2" />
543+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
544544
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
545-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.3" />
546-
<PackageReference Include="Avalonia.Themes.Simple" Version="11.1.3" />
547-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
545+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
546+
<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.3" />
547+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
548548
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
549-
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
549+
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
550550
<PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
551551
<PackageReference Include="TextCopy" Version="6.2.1" />
552552
</ItemGroup>

ZXBasicStudioTest/ZXBasicStudioTest.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="coverlet.collector" Version="6.0.2">
13+
<PackageReference Include="coverlet.collector" Version="6.0.4">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>
1717
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
18-
<PackageReference Include="xunit" Version="2.9.0" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
18+
<PackageReference Include="xunit" Version="2.9.3" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
2020
<PrivateAssets>all</PrivateAssets>
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
</PackageReference>

0 commit comments

Comments
 (0)