1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 14:52:19 +03:00

GH-297 Handle also paths with spaces

This commit is contained in:
Tae Won Ha 2016-11-24 00:48:49 +01:00
parent ea9407b5ad
commit 2dde944a46
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 16 additions and 3 deletions

View File

@ -11,13 +11,14 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSInteger handle;
/**
* Full path
* Full path without escaping, e.g. /some/path with spaces/file.txt
*/
@property (nonatomic, retain, nullable) NSString *fileName;
/**
* Only the file name
*/
@property (nonatomic, readonly, nullable) NSString *name;
@property (nonatomic, readonly, nullable) NSURL *url;
@property (nonatomic, readonly) bool isReadOnly;
@property (nonatomic, readonly) bool isDirty;
@property (nonatomic, readonly) bool isCurrent;

View File

@ -90,6 +90,17 @@
return self.fileName.lastPathComponent;
}
- (NSURL *)url {
if (self.fileName == nil) {
return nil;
}
NSString *percentageEscaped = [self.fileName stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLQueryAllowedCharacterSet]
];
return [[NSURL alloc] initWithString:percentageEscaped];
}
- (bool)isTransient {
if (self.isDirty) {
return NO;

View File

@ -112,11 +112,12 @@ extension BufferListComponent {
}
fileprivate func text(for buffer: NeoVimBuffer) -> NSAttributedString {
guard let name = buffer.name, let fileName = buffer.fileName else {
guard let name = buffer.name else {
return NSAttributedString(string: "No Name")
}
guard let url = URL(string: fileName) else {
guard let url = buffer.url else {
NSLog("WARN No URL for \(buffer.fileName)")
return NSAttributedString(string: name)
}