mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-24 22:33:52 +03:00
GH-309 Add isEqual to NeoVimBuffer
This commit is contained in:
parent
1750af1ce5
commit
3f7c51cdcb
@ -28,3 +28,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@interface NeoVimBuffer (Equality)
|
||||
|
||||
- (BOOL)isEqual:(id _Nullable)other;
|
||||
- (BOOL)isEqualToBuffer:(NeoVimBuffer * _Nullable)buffer;
|
||||
- (NSUInteger)hash;
|
||||
|
||||
@end
|
||||
|
@ -37,6 +37,29 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)other {
|
||||
if (other == self)
|
||||
return YES;
|
||||
if (!other || ![[other class] isEqual:[self class]])
|
||||
return NO;
|
||||
|
||||
return [self isEqualToBuffer:other];
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToBuffer:(NeoVimBuffer *)buffer {
|
||||
if (self == buffer)
|
||||
return YES;
|
||||
if (buffer == nil)
|
||||
return NO;
|
||||
if (self.handle != buffer.handle)
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return (NSUInteger) self.handle;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||
[coder encodeObject:@(self.handle) forKey:@"handle"];
|
||||
[coder encodeObject:self.fileName forKey:@"fileName"];
|
||||
|
14
SwiftNeoVim/NeoVimObjectsExtensions.swift
Normal file
14
SwiftNeoVim/NeoVimObjectsExtensions.swift
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Tae Won Ha - http://taewon.de - @hataewon
|
||||
* See LICENSE
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
extension NeoVimTab {
|
||||
|
||||
public func allBuffers() -> [NeoVimBuffer] {
|
||||
return Array(Set(self.windows.map { $0.buffer }))
|
||||
}
|
||||
}
|
@ -181,7 +181,8 @@ public class NeoVimView: NSView, NSUserInterfaceValidations {
|
||||
|
||||
@IBAction public func debug1(_ sender: AnyObject!) {
|
||||
NSLog("DEBUG 1 - Start")
|
||||
NSLog("\(self.agent.tabs())")
|
||||
let buffers = self.agent.tabs().map { $0.allBuffers() }.flatMap { $0 }
|
||||
NSLog("\(Set(buffers))")
|
||||
NSLog("DEBUG 1 - End")
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,7 @@
|
||||
4B6A709C1D6507A000E12030 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
4B6B0A781DA2A1A500212D6D /* FileOutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B6B0A771DA2A1A500212D6D /* FileOutlineView.swift */; };
|
||||
4B854A1D1D31447C00E08DE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B854A1C1D31447C00E08DE1 /* main.m */; };
|
||||
4B8AC0441DBCB3A2007CCC9B /* NeoVimObjectsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */; };
|
||||
4B97E2CC1D33F53D00FC0660 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B97E2CE1D33F53D00FC0660 /* MainWindow.xib */; };
|
||||
4B9A15241D2993DA009F9F67 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
4B9A15261D2993DF009F9F67 /* SwiftNeoVim.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
@ -312,6 +313,7 @@
|
||||
4B6B0A771DA2A1A500212D6D /* FileOutlineView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileOutlineView.swift; sourceTree = "<group>"; };
|
||||
4B854A1A1D31447C00E08DE1 /* NeoVimServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NeoVimServer; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4B854A1C1D31447C00E08DE1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimObjectsExtensions.swift; sourceTree = "<group>"; };
|
||||
4B97E2CD1D33F53D00FC0660 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainWindow.xib; sourceTree = "<group>"; };
|
||||
4BAD81D41D80B5D8004F91AE /* OpenQuicklyFileViewRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenQuicklyFileViewRow.swift; sourceTree = "<group>"; };
|
||||
4BAD84E71D7CA8FC00A79CC3 /* OpenQuicklyFilterOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenQuicklyFilterOperation.swift; sourceTree = "<group>"; };
|
||||
@ -518,6 +520,7 @@
|
||||
4B1BB3521D16C5E500CA4FEF /* InputTestView.swift */,
|
||||
4BEE79141D16D2100012EDAA /* DispatchUtils.swift */,
|
||||
4BF6E29B1D34153C0053FA76 /* KeyUtils.swift */,
|
||||
4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */,
|
||||
);
|
||||
path = SwiftNeoVim;
|
||||
sourceTree = "<group>";
|
||||
@ -1008,6 +1011,7 @@
|
||||
4BDF64251D08CAB000D47E1D /* MMCoreTextView.m in Sources */,
|
||||
4BDD058C1DBBC50000D1B405 /* NeoVimWindow.m in Sources */,
|
||||
1929BEB90DCDAF7A2B68C886 /* ColorUtils.swift in Sources */,
|
||||
4B8AC0441DBCB3A2007CCC9B /* NeoVimObjectsExtensions.swift in Sources */,
|
||||
4B4192181D0C52D700A0BEB2 /* Grid.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user