-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text cursor not moving to the correct location with ctrl+c -> ctrl+v #1950
Comments
The problem you are having is that you must have copy pasted the code from some editor that uses |
Just noticed it was the tab causing the issues. Do you mind linking the PR. I don't see it on the list. |
There isn't a PR specifically for converting tabs to spaces. The way I commit changes and create PRs has changed recently. I used to submit many changes into single PRs but now I create separate ones for each separate change set defined by an issue, a feature, improvement, etc... The (incorrect) code that changes Tabs to spaces can be found in PR #1700 but that is an old type of PR so it is set to draft. All the non-draft PRs should (eventually) add up to the draft PRs. When I wrote the reply to your issue I was certain that the code was added to one of the smaller PRs but now I am not sure and I'm not going to search for it because that's a pita. I know I said that the code that changes tabs to spaces is waiting to be merged, but if it isn't already it will soon be and the code will hopefully also be correct. Tabs are really evil and using tabs in the text editor causes many problems besides the ones you found. Search replace, syntax coloring, error markings and many more are affected by them because tabs break the line, column coordinate system we use to locate text in the editor. Initially tabs were incorporated to the line,column coordinates but that makes the code a lot more complex than it needs to be if we simply avoid them altogether. As such, code created within the editor will always be tab free so the only way to introduce tabs is by pasting them into the code. You should avoid doing that and IMHO we should use spaces in all the editors that allow them, but it is understandably difficult to avoid the occasional tab to slip by being invisible as they are, so rest assured that this is an important part of the text editor which will not be overlooked or neglected. In fact, it deserves a PR of its own even if the code exists in another PR already. If you are interested look forward to it! |
Thanks for the explanation. I like spaces as well because they are consistent between editors. This case is just as you described. I copied code from another program which happens to use tabs so it wasn't really apparent in imhex until I used notepad++ and saw the tabs. |
…n libwolv repo. It uses function added there to remove tabs if they exist on the provider. Additionally, any pasted tab will be translated to spaces automatically. This code was tested successfully using the pattern posted in the issue.
I finished with the fixes for this issues. I extended and implemented correctly the changes hinted in the draft PR. Fix changes exist in two PRs one to the libwolv repository and the other to PR #1951. I tested the pattern you posted and while it shows both errors without the fixes, they are no longer reproducible when fixes are applied. |
Operating System
Windows
What's the issue you encountered?
Wrong cursor position that cause multiple issues. Seems to happen in just some lines and not the whole document.
How can the issue be reproduced?
Selecting a line of code then copy paste multiple times. Results in the cursor positioning in the wrong location. Using ctrl+z to revert the changes will keep some of the text on the editor.
Additionally double click on a word will select the previous text block instead of the word you where hovering.
ImHex Version
1.35.4
ImHex Build Type
Installation type
Portable
Additional context?
Reproduced in two computers with windows 10. Pattern script: https://github.com/german77/TheDudeToHuman/blob/master/imhex.pattern
The text was updated successfully, but these errors were encountered: