Comments (3)
Humm, self help:🤪
I just peeked the code and tried something in a playground. I guess I can say that this issue is caused by replaceCharacters
with a wrong range.
import AppKit
import Foundation
import PlaygroundSupport
var textStorage: NSTextStorage = NSTextStorage()
textStorage.replaceCharacters(
in: NSRange(location: 0, length: textStorage.string.count),
with: "hello,世界!😀")
textStorage.string.count
textStorage.length
let range = NSRange(location: 0, length: textStorage.string.count)
//let range = NSRange(location: 0, length: textStorage.length)
textStorage.replaceCharacters(in: range, with: "")
let length = textStorage.string.count
As we can see, different from string.count
, a utf-16 char in NSTextStorage
is not length one.
Replace textStorage.string.count
with a textStorage.length
helps a lot:
This is not a big problem, I am now working on this, PR to solve it soon.
from boop.
Oh wow, this explains a lot of issues I've been seeing lately but could not pinpoint... Thank you so much for taking the time to document it, research it, and fix it! It would have taken me a while to realize all those were linked, and even more so to figure out how to address it.
I'll test your changes and merge it all in. Thank you again!
from boop.
Merged, thanks for the help!
from boop.
Related Issues (20)
- Feature Request: Suggested actions
- can't select a script HOT 1
- Feature request: Persist boop
- [Feature] Generate current timestamp
- Decouple Scripts from main repo
- JSON to Query String action should URL encode parameters
- Work with Tabs HOT 2
- QR Code
- Feature Request: asn1js support HOT 1
- [Feat] Ability to Change Activation Key HOT 4
- Script to convert yaml to .properties files
- Feature Request: Open Scripts Folder
- Bug Report: unexpected replacement of tabs with spaces
- [FR] Read custom scripts from subdirectories inside the Customer script folder location
- Feature Request: convert clipboard to UUID HOT 3
- RangeError. Internal Error. Icu error in custom script HOT 1
- Can't open *.nim file
- Dead project? HOT 1
- Ascii to Text HOT 1
- Built-in Format Json command loses precision on high Int64 values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boop.