Posted 19 years ago
by Kasper
Hi,
I'm building some Extended Search & Replace for my application, which allows the user to search through a range of files and get the results listed. It can be performed on both the currently open documents, as well as all files in a specified folder and so on. To search through the currently open files, I simply loop through them and get the contents from the Text property of the SyntaxEditor. Now, each time I find an instance of the search text, I log the position of it. Now, when user wishes to jump to one of the results, I simply set the Editor.SelectedView.Selection.StartOffset property to the logged start position. This works just fine. However, if I wish to search through a file, I simply get the contents by doing a File.ReadAllText() and then use the same method to search through the string. Now, when the user wishes to look at the found result, I load the file in my application, and uses the same way (Editor.SelectedView.Selection.StartOffset) to set the focus at the right position. Unfortunately, this does not work. The start position I have logged can not be used directly for the SyntaxEditor, if the text is not obtained from it. I'm thinking that this could be related to some sort of hidden characters being added when loaded into SyntaxEditor or something like that. Perhaps you can tell me what's going and, and maybe even a way to deal with it? :)
I'm building some Extended Search & Replace for my application, which allows the user to search through a range of files and get the results listed. It can be performed on both the currently open documents, as well as all files in a specified folder and so on. To search through the currently open files, I simply loop through them and get the contents from the Text property of the SyntaxEditor. Now, each time I find an instance of the search text, I log the position of it. Now, when user wishes to jump to one of the results, I simply set the Editor.SelectedView.Selection.StartOffset property to the logged start position. This works just fine. However, if I wish to search through a file, I simply get the contents by doing a File.ReadAllText() and then use the same method to search through the string. Now, when the user wishes to look at the found result, I load the file in my application, and uses the same way (Editor.SelectedView.Selection.StartOffset) to set the focus at the right position. Unfortunately, this does not work. The start position I have logged can not be used directly for the SyntaxEditor, if the text is not obtained from it. I'm thinking that this could be related to some sort of hidden characters being added when loaded into SyntaxEditor or something like that. Perhaps you can tell me what's going and, and maybe even a way to deal with it? :)