{"action":"created","issue":{"url":"https://api.github.com/repos/jacobslusser/ScintillaNET/issues/160","labels_url":"https://api.github.com/repos/jacobslusser/ScintillaNET/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/jacobslusser/ScintillaNET/issues/160/comments","events_url":"https://api.github.com/repos/jacobslusser/ScintillaNET/issues/160/events","html_url":"https://github.com/jacobslusser/ScintillaNET/issues/160","id":121639605,"number":160,"title":"Finding locations of text and \"porting\" to it","user":{"login":"robmburke","id":11561820,"avatar_url":"https://avatars.githubusercontent.com/u/11561820?v=3","gravatar_id":"","url":"https://api.github.com/users/robmburke","html_url":"https://github.com/robmburke","followers_url":"https://api.github.com/users/robmburke/followers","following_url":"https://api.github.com/users/robmburke/following{/other_user}","gists_url":"https://api.github.com/users/robmburke/gists{/gist_id}","starred_url":"https://api.github.com/users/robmburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robmburke/subscriptions","organizations_url":"https://api.github.com/users/robmburke/orgs","repos_url":"https://api.github.com/users/robmburke/repos","events_url":"https://api.github.com/users/robmburke/events{/privacy}","received_events_url":"https://api.github.com/users/robmburke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-11T05:14:42Z","updated_at":"2015-12-11T05:26:50Z","closed_at":null,"body":"I am trying to create a window that will grab the text from every file in the project and find the \"TODO:\" comments.  Here is the code:\r\n\r\n    //Method on ToDo Form to populate locations and store the expected cursor positions\r\n\tList<ToDoMatch> matches = new List<ToDoMatch>();\r\n\r\n\tforeach (FileInfo file in Files)\r\n\t{\r\n\t\tusing (Scintilla scintilla = new Scintilla())\r\n\t\t{\r\n\t\t\tusing (StreamReader reader = new StreamReader(file.FullName))\r\n\t\t\t{\r\n\t\t\t\tscintilla.Text = reader.ReadToEnd();\r\n\t\t\t}\r\n\r\n\t\t\tint result = 0;\r\n\t\t\tscintilla.CurrentPosition = 0;\r\n\r\n\t\t\tdo\r\n\t\t\t{\r\n\t\t\t\tscintilla.TargetStart = scintilla.CurrentPosition;\r\n\t\t\t\tscintilla.TargetEnd = scintilla.TextLength;\r\n\r\n\t\t\t\tresult = scintilla.SearchInTarget(\"TODO:\");\r\n\r\n\t\t\t\tif (result != -1)\r\n\t\t\t\t{\r\n\t\t\t\t\tscintilla.SetSel(scintilla.TargetStart, scintilla.TargetEnd);\r\n\r\n\t\t\t\t\tLine line = scintilla.Lines[scintilla.CurrentLine];\r\n\r\n\t\t\t\t\tmatches.Add(new ToDoMatch()\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tFile = file,\r\n\t\t\t\t\t\tSource = file.Name,\r\n\t\t\t\t\t\tLineText = string.Format(\"Line {0}: {1}\", line.Index + 1, line.Text),\r\n\t\t\t\t\t\tPosition = scintilla.TargetStart\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t} while (result != -1);\r\n\t\t};\r\n\t}\r\n\r\n    //Method on Main Form to open editor, and place the cursor\r\n\tpublic void DisplayToDo(ToDoLocater locater)\r\n\t{\r\n\t\tDisplayEditor(locater.File);\r\n\t\t\r\n\t\tScintilla scintilla = (Scintilla)workspace.SelectedTab.Controls[1];\r\n\t\tscintilla.Select();\r\n\t\tscintilla.Focus();\r\n\r\n\t\tscintilla.AnchorPosition = locater.Position;\r\n\t\tscintilla.CurrentPosition = locater.Position;\r\n\t}\r\n\r\nThe problem is that when I use the TargetStart value to try to put the cursor at that position, it's off by like 2 spaces past the position I am expecting for the first match.  Subsequent, matches in the same file are an extra 2 spaces from the expected starting point.\r\n\r\nBasically, it seems my search method above seems to be reporting a number that is different once I actually do open a tab with an editor in it and try to place it at the number I am given; it doesn't match up with what is on the screen"},"comment":{"url":"https://api.github.com/repos/jacobslusser/ScintillaNET/issues/comments/163844632","html_url":"https://github.com/jacobslusser/ScintillaNET/issues/160#issuecomment-163844632","issue_url":"https://api.github.com/repos/jacobslusser/ScintillaNET/issues/160","id":163844632,"user":{"login":"jacobslusser","id":345183,"avatar_url":"https://avatars.githubusercontent.com/u/345183?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobslusser","html_url":"https://github.com/jacobslusser","followers_url":"https://api.github.com/users/jacobslusser/followers","following_url":"https://api.github.com/users/jacobslusser/following{/other_user}","gists_url":"https://api.github.com/users/jacobslusser/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobslusser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobslusser/subscriptions","organizations_url":"https://api.github.com/users/jacobslusser/orgs","repos_url":"https://api.github.com/users/jacobslusser/repos","events_url":"https://api.github.com/users/jacobslusser/events{/privacy}","received_events_url":"https://api.github.com/users/jacobslusser/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T05:26:50Z","updated_at":"2015-12-11T05:26:50Z","body":"That's interesting. I'm not sure I know for sure what could be the cause, but I have a hunch if you are interested in exploring it. Do your files have a [Byte Order Mark (BOM)](https://en.wikipedia.org/wiki/Byte_order_mark)? If so, try removing it by saving your files in an editor that allows you to save without a BOM or use a Hex Editor to remove it and tell me if that makes a difference on those files."}}