Code Monkey home page Code Monkey logo

Comments (4)

danielsaidi avatar danielsaidi commented on June 19, 2024 2

Hi @rubenspessoa

Thank you for clarifying! I will look into this 👍

from keyboardkit.

danielsaidi avatar danielsaidi commented on June 19, 2024 1

Hi @rubenspessoa

Happy to hear that you like the library and thank you for letting me know about your problems.

KeyboardKit 8.5.1 adjusted some autocomplete bugs when it comes to empty text. Can you upgrade and see if it solves the problem?

from keyboardkit.

danielsaidi avatar danielsaidi commented on June 19, 2024 1

This will be fixed in 8.7 and available in the v8.7 branch later this week.

from keyboardkit.

rubenspessoa avatar rubenspessoa commented on June 19, 2024

Hi @danielsaidi,



Thanks for your response. I’ve updated to the latest version (8.5.2) version but unfortunately can still reproduce the bug. I’ll share the stacktrace and my suspicion:





1. KeyboardContext+ProxyBridging.insertAutocompleteSuggestion(_ suggestion: Autocomplete.Suggestion,, tryInsertSpace: Bool = true)
2. UITextDocumentProxy+Autocomplete.insertAutocompleteSuggestion(_ suggestion: Autocomplete.Suggestion, tryInsertSpace: Bool = true)
3. UITextDocumentProxy+Words.replaceCurrentWord(with replacement: String)


That’s where the problem occurs, in the first line of the replaceCurrentWord method we have:

guard let word = currentWord else { return }

But currentWord resolves as nil when the context is empty. It's a computed variable that's created as following:


var currentWord: String? {
  let pre = currentWordPreCursorPart
  let post = currentWordPostCursorPart
  if pre == nil && post == nil { return nil }
  return (pre ?? "") + (post ?? "")
}


And since the context is empty, pre == nil resolves to true, post == nil also resolves to true and the currentWord returns nil.

Since it resolves to nil, replaceCurrentWord returns early and, following the normal app flow, just the space is added to the context.

I'm not sure if any changes here could result in major consequences in the app functionality, but I hope this helps the team to spot the issue and improve the library even further! Thanks guys, let me know if I can help in anything.

from keyboardkit.

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.