Coder Social home page Coder Social logo

Comments (4)

evermeer avatar evermeer commented on August 20, 2024 1

Solved!

Instead of using:
self.attributedText.string.characters.count
I am now using:
(self.attributedText.string as NSString).length

I will push a new version in a couple of minutes...

from attributedtextview.

evermeer avatar evermeer commented on August 20, 2024

Indeed there is something strange when using /r What's also strange that this behaviour only happens with the last url and only if there is nothing behind it. If you add 2 extra characters at the end (can be spaces) then it's ok again. I will try to find out what this could be.

from attributedtextview.

evermeer avatar evermeer commented on August 20, 2024

I did find the source of the problem. When doing a character count \r and \n will return 1 but a \r\n will also return 1. I search in a range using that character count. So the search will be executed in the string that is 2 characters short.

Here you can see this:

let cr = "\r"
cr.characters.count // 1
let lf = "\n"
lf.characters.count // 1
let crlf = "\r\n"
crlf.characters.count // 1

My quick solution would be replacing the \r\n into a \n
I will try out to find more information about this Swift bug / strange behaviour.

from attributedtextview.

evermeer avatar evermeer commented on August 20, 2024

It's now pushed as version 0.5.3

from attributedtextview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.