{"action":"created","issue":{"url":"https://api.github.com/repos/NLog/NLog/issues/689","labels_url":"https://api.github.com/repos/NLog/NLog/issues/689/labels{/name}","comments_url":"https://api.github.com/repos/NLog/NLog/issues/689/comments","events_url":"https://api.github.com/repos/NLog/NLog/issues/689/events","html_url":"https://github.com/NLog/NLog/pull/689","id":72535860,"number":689,"title":"Make alignment stay consistent when fixed-length truncation occurs.","user":{"login":"logiclrd","id":2349379,"avatar_url":"https://avatars.githubusercontent.com/u/2349379?v=3","gravatar_id":"","url":"https://api.github.com/users/logiclrd","html_url":"https://github.com/logiclrd","followers_url":"https://api.github.com/users/logiclrd/followers","following_url":"https://api.github.com/users/logiclrd/following{/other_user}","gists_url":"https://api.github.com/users/logiclrd/gists{/gist_id}","starred_url":"https://api.github.com/users/logiclrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/logiclrd/subscriptions","organizations_url":"https://api.github.com/users/logiclrd/orgs","repos_url":"https://api.github.com/users/logiclrd/repos","events_url":"https://api.github.com/users/logiclrd/events{/privacy}","received_events_url":"https://api.github.com/users/logiclrd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NLog/NLog/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/NLog/NLog/labels/has%20unittests","name":"has unittests","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-01T22:13:35Z","updated_at":"2015-05-04T16:48:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NLog/NLog/pulls/689","html_url":"https://github.com/NLog/NLog/pull/689","diff_url":"https://github.com/NLog/NLog/pull/689.diff","patch_url":"https://github.com/NLog/NLog/pull/689.patch"},"body":"The `PaddingLayoutRenderWrapper` class implements left and right padding, based on the sign of the `Padding` parameter. However, something unexpected happens when `FixedLength` is turned on, if the string is too long to fit:\r\n```\r\n\"        T\" <= \"T\"\r\n\"       Th\" <= \"Th\"\r\n\"      Thi\" <= \"Thi\"\r\n\"     This\" <= \"This\"\r\n\"    This \" <= \"This \"\r\n\"   This m\" <= \"This m\"\r\n\"  This me\" <= \"This me\"\r\n\" This mes\" <= \"This mes\"\r\n\"This mess\" <= \"This mess\"\r\n\"This mess\" <= \"This messa\"\r\n\"This mess\" <= \"This messag\"\r\n\"This mess\" <= \"This message\"\r\n\"This mess\" <= \"This message is\"\r\n\"This mess\" <= \"This message is too\"\r\n\"This mess\" <= \"This message is too long\"\r\n```\r\nWhat's happening, in effect, is that we're getting right-alignment of text shorter than the pad length, but then left-alignment of text that is too long. Intuitively, this sequence should end like this:\r\n```\r\n\" This mes\" <= \"This mes\"\r\n\"This mess\" <= \"This mess\"\r\n\"his messa\" <= \"This messa\"\r\n\"is messag\" <= \"This messag\"\r\n\"s message\" <= \"This message\"\r\n\"essage is\" <= \"This message is\"\r\n\"ge is too\" <= \"This message is too\"\r\n\" too long\" <= \"This message is too long\"\r\n```\r\nWhen `Padding` is negative, the current behaviour is what you'd expect:\r\n```\r\n\"T        \" <= \"T\"\r\n\"Th       \" <= \"Th\"\r\n\"Thi      \" <= \"Thi\"\r\n\"This     \" <= \"This\"\r\n\"This     \" <= \"This \"\r\n\"This m   \" <= \"This m\"\r\n\"This me  \" <= \"This me\"\r\n\"This mes \" <= \"This mes\"\r\n\"This mess\" <= \"This mess\"\r\n\"This mess\" <= \"This messa\"\r\n\"This mess\" <= \"This messag\"\r\n\"This mess\" <= \"This message\"\r\n\"This mess\" <= \"This message is\"\r\n\"This mess\" <= \"This message is too\"\r\n\"This mess\" <= \"This message is too long\"\r\n```\r\nThis pull request updates `PaddingLayoutRendererWrapper.cs` to remove characters from the start of the string instead of the end when `Padding` is positive. Negative values continue to remove characters from the end of the string. In effect, this means that the padding action, whether it is to add or remove characters, always modifies the same end of the string.\r\n\r\nThe pull request also adds unit tests that verify this behaviour."},"comment":{"url":"https://api.github.com/repos/NLog/NLog/issues/comments/98776425","html_url":"https://github.com/NLog/NLog/pull/689#issuecomment-98776425","issue_url":"https://api.github.com/repos/NLog/NLog/issues/689","id":98776425,"user":{"login":"logiclrd","id":2349379,"avatar_url":"https://avatars.githubusercontent.com/u/2349379?v=3","gravatar_id":"","url":"https://api.github.com/users/logiclrd","html_url":"https://github.com/logiclrd","followers_url":"https://api.github.com/users/logiclrd/followers","following_url":"https://api.github.com/users/logiclrd/following{/other_user}","gists_url":"https://api.github.com/users/logiclrd/gists{/gist_id}","starred_url":"https://api.github.com/users/logiclrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/logiclrd/subscriptions","organizations_url":"https://api.github.com/users/logiclrd/orgs","repos_url":"https://api.github.com/users/logiclrd/repos","events_url":"https://api.github.com/users/logiclrd/events{/privacy}","received_events_url":"https://api.github.com/users/logiclrd/received_events","type":"User","site_admin":false},"created_at":"2015-05-04T16:48:31Z","updated_at":"2015-05-04T16:48:31Z","body":"There we go. :-)"}}