{"action":"created","issue":{"url":"https://api.github.com/repos/tempelmann/custom-editfield/issues/9","labels_url":"https://api.github.com/repos/tempelmann/custom-editfield/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/tempelmann/custom-editfield/issues/9/comments","events_url":"https://api.github.com/repos/tempelmann/custom-editfield/issues/9/events","html_url":"https://github.com/tempelmann/custom-editfield/issues/9","id":61313939,"number":9,"title":"Auto completion drawing issue","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tempelmann/custom-editfield/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/tempelmann/custom-editfield/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/tempelmann/custom-editfield/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-14T00:28:16Z","updated_at":"2015-03-24T18:41:40Z","closed_at":null,"body":"```\nCEF bug: wenn man \"som\" tippt, erscheint \"e…\" an falscher Stelle - auch, wenn \nman dann Return drückt!\n\nWhat steps will reproduce the problem?\n1. Run the project, make sure \"Enable autocomplete\" as well as \"Indent visually \nonly\" are checked.\n2. Go to a line that shows an indented \"end\"\n3.  Move the cursor past the \"end\", type a blank, then \"som\".\n\nWhat is the expected output? What do you see instead?\nThe \"e..\" should appear right behind \"som\".\n\nPlease use labels and text to provide additional information.\nThe \"e..\" appears somewhere else, e.g. underneath \"som\" or futher out.\n\nThe issue does not occur if \"Indent visually only\" is off.\n\nObviously autocompletion drawing does not consider the visual indentation \noffset correctly.\n\n```\n\nOriginal issue reported on code.google.com by `tempelmann@gmail.com` on 18 Mar 2014 at 11:39"},"comment":{"url":"https://api.github.com/repos/tempelmann/custom-editfield/issues/comments/85637113","html_url":"https://github.com/tempelmann/custom-editfield/issues/9#issuecomment-85637113","issue_url":"https://api.github.com/repos/tempelmann/custom-editfield/issues/9","id":85637113,"user":{"login":"rogermeier","id":194280,"avatar_url":"https://avatars.githubusercontent.com/u/194280?v=3","gravatar_id":"","url":"https://api.github.com/users/rogermeier","html_url":"https://github.com/rogermeier","followers_url":"https://api.github.com/users/rogermeier/followers","following_url":"https://api.github.com/users/rogermeier/following{/other_user}","gists_url":"https://api.github.com/users/rogermeier/gists{/gist_id}","starred_url":"https://api.github.com/users/rogermeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogermeier/subscriptions","organizations_url":"https://api.github.com/users/rogermeier/orgs","repos_url":"https://api.github.com/users/rogermeier/repos","events_url":"https://api.github.com/users/rogermeier/events{/privacy}","received_events_url":"https://api.github.com/users/rogermeier/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T18:41:40Z","updated_at":"2015-03-24T18:41:40Z","body":"I think I'm stuck. Here is what I was able to find:\r\n- drawContents uses the AutocompleteSuggestionInsertionX property to determine where do draw the autocomple suggestion. When a key is typed, this property is seemingly not updated to reflect the just added character.\r\n- AutocompleteSuggestionInsertionX is updated in the AutoCompleteEOL method, which executes as a result of the keydown event, prior to drawContents.\r\n- AutoCompleteEOL calls XYAtCharPos to update AutocompleteSuggestionInsertionX.\r\n- XYAtCharPos calls XposForOffset for the current line to calculate the x position.\r\n- XposForOffset the calls TextLine.TextWidth, which is where the issue appears to happen. If I inspect the text variable in TextLine.TextWidth it does not contain the typed character yet.\r\n\r\nIt appears that, at the time AutoCompleteEOL is executed after a new character is typed, the TextLine that is used to calculate where the autocomplete suggestion needs to go doesn't contain the new character yet. However, I have not been able to figure why that is exactly. \r\n\r\nThe call stack is as follows when a new character is pressed:\r\nCustomEditField.AutoCompleteEOL\r\nCustomEditField.changeSelection\r\nCustomEditField.private_replace\r\nCustomEditField.Insert\r\nCustomEditField.HandleKeyDown\r\nCustomEditField.Event.KeyDown\r\n\r\nAnd here is the call stack when backspace is pressed (and autocomplete works):\r\nCustomEditField.AutoCompleteEOL\r\nCustomEditField.changeSelection\r\nCustomEditField.private_remove\r\nCustomEditField.DeleteChars\r\nCustomEditField.HandleKeyDown\r\nCustomEditField.Event.KeyDown\r\n\r\nIf I had to guess, I would say the difference is somewhere in either .private_replace or .insert, but I can't figure out where."}}