Created
June 28, 2021 22:20
-
-
Save gtokman/af1ea26a8e43b6e0125d943832b2b947 to your computer and use it in GitHub Desktop.
Get full context
This file contains hidden or 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
// Grab everything before the cursor | |
var before = textDocumentProxy.documentContextBeforeInput | |
var completePriorString = "" | |
while let beforeInput = before, !beforeInput.isEmpty { | |
completePriorString = beforeInput | |
let length = beforeInput.lengthOfBytes(using: String.Encoding.utf8) | |
textDocumentProxy.adjustTextPosition(byCharacterOffset: -length) | |
Thread.sleep(forTimeInterval: 0.01) | |
before = textDocumentProxy.documentContextBeforeInput | |
} | |
// Move the cursor back to the original position | |
textDocumentProxy | |
.adjustTextPosition(byCharacterOffset: completePriorString.count) | |
Thread.sleep(forTimeInterval: 0.01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment