{"action":"created","issue":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/652","labels_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/652/labels{/name}","comments_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/652/comments","events_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/652/events","html_url":"https://github.com/Hammerspoon/hammerspoon/issues/652","id":118433183,"number":652,"title":"styledtext:setString() confusion","user":{"login":"chdiza","id":3311113,"avatar_url":"https://avatars.githubusercontent.com/u/3311113?v=3","gravatar_id":"","url":"https://api.github.com/users/chdiza","html_url":"https://github.com/chdiza","followers_url":"https://api.github.com/users/chdiza/followers","following_url":"https://api.github.com/users/chdiza/following{/other_user}","gists_url":"https://api.github.com/users/chdiza/gists{/gist_id}","starred_url":"https://api.github.com/users/chdiza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chdiza/subscriptions","organizations_url":"https://api.github.com/users/chdiza/orgs","repos_url":"https://api.github.com/users/chdiza/repos","events_url":"https://api.github.com/users/chdiza/events{/privacy}","received_events_url":"https://api.github.com/users/chdiza/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-11-23T17:41:34Z","updated_at":"2015-11-23T19:32:40Z","closed_at":"2015-11-23T18:29:49Z","body":"When reading the docs for hs.styledtext:setString(), I'm under the impression that it should behave as follows.  I have a styledtext object `foo`, the string of which is \"onetwothree\".  If I do:\r\n`foo:setString(\"two\")` then I should get back a styledtext object whose string is \"two\".  In fact, I get one whose string is \"twotwothree\".\r\n\r\nAm I misunderstanding the docs?  If so, how can I get the expected behavior?"},"comment":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/comments/159038526","html_url":"https://github.com/Hammerspoon/hammerspoon/issues/652#issuecomment-159038526","issue_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/652","id":159038526,"user":{"login":"asmagill","id":8139480,"avatar_url":"https://avatars.githubusercontent.com/u/8139480?v=3","gravatar_id":"","url":"https://api.github.com/users/asmagill","html_url":"https://github.com/asmagill","followers_url":"https://api.github.com/users/asmagill/followers","following_url":"https://api.github.com/users/asmagill/following{/other_user}","gists_url":"https://api.github.com/users/asmagill/gists{/gist_id}","starred_url":"https://api.github.com/users/asmagill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmagill/subscriptions","organizations_url":"https://api.github.com/users/asmagill/orgs","repos_url":"https://api.github.com/users/asmagill/repos","events_url":"https://api.github.com/users/asmagill/events{/privacy}","received_events_url":"https://api.github.com/users/asmagill/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T19:32:40Z","updated_at":"2015-11-23T19:32:40Z","body":"ANSI isn't a state for the string, it's a conversion of certain sequences into NSAttributedString attributes.  If the new string also contains ANSI escape sequences, you need to do something like `foo = foo:setString(hs.styledtext.ansi(newString, { defaultAttributes }))`"}}