{"action":"created","issue":{"url":"https://api.github.com/repos/atom/atom/issues/5658","labels_url":"https://api.github.com/repos/atom/atom/issues/5658/labels{/name}","comments_url":"https://api.github.com/repos/atom/atom/issues/5658/comments","events_url":"https://api.github.com/repos/atom/atom/issues/5658/events","html_url":"https://github.com/atom/atom/pull/5658","id":58411951,"number":5658,"title":":bug: Do not modify excess whitespace when modifying indentation","user":{"login":"driskell","id":939815,"avatar_url":"https://avatars.githubusercontent.com/u/939815?v=3","gravatar_id":"","url":"https://api.github.com/users/driskell","html_url":"https://github.com/driskell","followers_url":"https://api.github.com/users/driskell/followers","following_url":"https://api.github.com/users/driskell/following{/other_user}","gists_url":"https://api.github.com/users/driskell/gists{/gist_id}","starred_url":"https://api.github.com/users/driskell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/driskell/subscriptions","organizations_url":"https://api.github.com/users/driskell/orgs","repos_url":"https://api.github.com/users/driskell/repos","events_url":"https://api.github.com/users/driskell/events{/privacy}","received_events_url":"https://api.github.com/users/driskell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-20T21:20:03Z","updated_at":"2015-03-11T12:28:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/atom/atom/pulls/5658","html_url":"https://github.com/atom/atom/pull/5658","diff_url":"https://github.com/atom/atom/pull/5658.diff","patch_url":"https://github.com/atom/atom/pull/5658.patch"},"body":"This is a proposal for fixing #5642 and I'd welcome feedback on if this is the right approach or not?\r\n\r\nThe problem, is copying pasting PHPDoc code at an indented level, with hard tabs on, loses the asterisk alignment:\r\n\r\n![example](https://cloud.githubusercontent.com/assets/939815/6273202/41e81dbe-b865-11e4-8ea5-a5354bdbb50c.gif)\r\n\r\n**Root Cause**\r\n\r\nSeems inside Atom, in the case of encountering soft tabs in a hard tab file... it can return a *floating point* indentation level, such as 1.5 in this instance (tab+half-tab). When rebuilding the indentation (it calls setIndentationForBufferRow for each line), this calls @buildIndentString with 1.5 which gets converted to integer: 1. ALL leading whitespace is then replaced by this new indentation - so we lose the space that aligns the asterisk.\r\n\r\nThe tests seem to point to floating point indentation levels being allowed. Yet I can find nowhere where it is useful. Most places just Math.ceil(). And with hard tabs it doesn't even make sense.\r\n\r\nThis patch attempts to remove all the floating points (it leaves the Math.ceil calls - they're harmless and can be cleaned later if this turns out the right approach.). It then has a function for \"modifying\" whitespace to change its indentation level, while paying attention to straggling spacing like that in the PHPDoc comments in the image above. It also adds a couple API for handling indentation changes that can be used elsewhere.\r\n\r\nOnly thing I'm not too happy with is the overlap between my \"setIndentLevelForRow\" and the existing \"setIndentationForBufferRow\" - I'm sure mine follows correct naming convention but existing doesn't. It is the existing one that is called when pasting though."},"comment":{"url":"https://api.github.com/repos/atom/atom/issues/comments/78253496","html_url":"https://github.com/atom/atom/pull/5658#issuecomment-78253496","issue_url":"https://api.github.com/repos/atom/atom/issues/5658","id":78253496,"user":{"login":"50Wliu","id":2766036,"avatar_url":"https://avatars.githubusercontent.com/u/2766036?v=3","gravatar_id":"","url":"https://api.github.com/users/50Wliu","html_url":"https://github.com/50Wliu","followers_url":"https://api.github.com/users/50Wliu/followers","following_url":"https://api.github.com/users/50Wliu/following{/other_user}","gists_url":"https://api.github.com/users/50Wliu/gists{/gist_id}","starred_url":"https://api.github.com/users/50Wliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/50Wliu/subscriptions","organizations_url":"https://api.github.com/users/50Wliu/orgs","repos_url":"https://api.github.com/users/50Wliu/repos","events_url":"https://api.github.com/users/50Wliu/events{/privacy}","received_events_url":"https://api.github.com/users/50Wliu/received_events","type":"User","site_admin":false},"created_at":"2015-03-11T12:28:13Z","updated_at":"2015-03-11T12:28:13Z","body":"@kevinsawicki @benogle @nathansobo?"}}