-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fd20be
commit e58dd45
Showing
7 changed files
with
71 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// NSTextStorage+VimOperation.swift | ||
// XVim2 | ||
// | ||
// Created by pebble8888 on 2021/04/17. | ||
// Copyright © 2021 Shuichiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension NSTextStorage { | ||
@objc func validIndex(_ index: UInt) -> UInt { | ||
if index > self.string.count { | ||
return UInt(self.string.count) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
r-plus
Member
|
||
} | ||
return index | ||
} | ||
|
||
@objc func isEOF(_ index: UInt) -> Bool { | ||
let index = validIndex(index) | ||
return self.string.count == index | ||
This comment has been minimized.
Sorry, something went wrong.
r-plus
Member
|
||
} | ||
|
||
@objc func isLOL(_ index: UInt) -> Bool { | ||
let index = self.validIndex(index) | ||
return self.isEOF(index) == false && self.isNewline(index) == false && self.isNewline(index + 1) | ||
} | ||
|
||
@objc func isEOL(_ index: UInt) -> Bool { | ||
let index = self.validIndex(index) | ||
return self.isNewline(index) || self.isEOF(index) | ||
} | ||
|
||
@objc func isBOL(_ index: UInt) -> Bool { | ||
let index = self.validIndex(index) | ||
if 0 == index { | ||
return true | ||
} | ||
|
||
if self.isNewline(index - 1) { | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
@objc func isNewline(_ index: UInt) -> Bool { | ||
let index = self.validIndex(index) | ||
if index == self.string.count { | ||
return false // EOF is not a newline | ||
} | ||
|
||
return self.string.isNewline(index) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe this two lines...?
original implementation used
self.length
instead.for: #372