Skip to content

Commit

Permalink
Merge pull request #71 from LSViana/70-fix-unit-tests
Browse files Browse the repository at this point in the history
Fix unit tests
  • Loading branch information
LSViana authored Dec 3, 2023
2 parents fa16a7e + 7524a03 commit f933c59
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions YDotNet/Document/UndoManagers/UndoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using YDotNet.Document.UndoManagers.Events;
using YDotNet.Infrastructure;
using YDotNet.Native.UndoManager;
using YDotNet.Native.UndoManager.Events;

namespace YDotNet.Document.UndoManagers;

Expand Down Expand Up @@ -31,7 +32,7 @@ public UndoManager(Doc doc, Branch branch, UndoManagerOptions? options = null)
(_, action) =>
{
UndoManagerChannel.ObserveAddedCallback callback =
(_, undoEvent) => action(new UndoEvent(undoEvent));
(_, handle) => action(new UndoEvent(MemoryReader.ReadStruct<UndoEventNative>(handle)));

return (UndoManagerChannel.ObserveAdded(Handle, nint.Zero, callback), callback);
},
Expand All @@ -43,7 +44,7 @@ public UndoManager(Doc doc, Branch branch, UndoManagerOptions? options = null)
(_, action) =>
{
UndoManagerChannel.ObservePoppedCallback callback =
(_, undoEvent) => action(new UndoEvent(undoEvent));
(_, handle) => action(new UndoEvent(MemoryReader.ReadStruct<UndoEventNative>(handle)));

return (UndoManagerChannel.ObservePopped(Handle, nint.Zero, callback), callback);
},
Expand Down
2 changes: 2 additions & 0 deletions YDotNet/Native/UndoManager/Events/UndoEventNative.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Runtime.InteropServices;
using YDotNet.Infrastructure;
using YDotNet.Native.Document.State;

namespace YDotNet.Native.UndoManager.Events;

[StructLayout(LayoutKind.Sequential)]
internal struct UndoEventNative
{
public UndoEventKindNative KindNative { get; set; }
Expand Down
5 changes: 2 additions & 3 deletions YDotNet/Native/UndoManager/UndoManagerChannel.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System.Runtime.InteropServices;
using YDotNet.Native.UndoManager.Events;

namespace YDotNet.Native.UndoManager;

internal static class UndoManagerChannel
{
public delegate void ObserveAddedCallback(nint state, UndoEventNative undoEvent);
public delegate void ObserveAddedCallback(nint state, nint eventHandle);

public delegate void ObservePoppedCallback(nint state, UndoEventNative undoEvent);
public delegate void ObservePoppedCallback(nint state, nint eventHandle);

[DllImport(
ChannelSettings.NativeLib,
Expand Down

0 comments on commit f933c59

Please sign in to comment.