-
-
Notifications
You must be signed in to change notification settings - Fork 805
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
Ambigous cursor positions around invisible text in status buffer #2592
Comments
Yes, after setting |
I think instead of forcing some user settings trying to avoid the problem, we should try to find the cause of the problem. Is it a bug in emacs, or do we do something wrong? |
I think part of the problem is which newline characters we make invisible. Currently, the newline after the last line we want to stay is not made part of the overlay making text invisible. The newline after the last line of the text we want to hide is included in the overlay. |
That would refer to the choice mentioned in 83b59be, right?
I had noticed that |
I have been thinking the same, but not because I think it makes more sense. I think it makes less sense (and has drawbacks (e.g. the background color of headings of collapsed sections would not be in affect all the way to the right edge of the window anymore)), but this is how Org-mode does it (I assume for historic reasons) - so some of the edge cases have already been taken care of. Anyway changing this would be a major undertaking with unknown consequences - there might be more issues after the switch. So I won't do that just because of some feeling that things might be better if we do. However I do intend to rewrite the section code at some point, and then this will certainly be on my mind. That rewrite will entail much more than this though, so I won't do it anytime soon. This will likely involve switching to using EIEIO and the main goal will be to make it easier to create sections asynchronously and to cache washed sections. |
So let's talk about short- to mid-term solutions to this issue.
At least on an abstract level the cause is clear. As you said
There are edge cases and Magit hits a few of those. Views on whether these problems exist because Magit abuses overlays or whether we just use the only method available to do the things we want to do, are divided. It's a process and will require having lengthy conversations with the Emacs maintainers, and since I am trying to take a break right now and also don't have a prototype of the next-generation section code handy yet, I don't want to enter that now. So in the short run I don't think we have alternatives to disable the features that trigger the issues. Like setting |
Jonas Bernoulli notifications@github.com writes:
I would like to discuss this on emacs-dev. When the problem happens, Dunno what the correct solution for Magit would be. If you give me some |
I once opened an issue about this, https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19188, but did not follow through. Turns out I still have some draft replies sitting around though ;-) (At one point I talk about |
Thanks. Stefan made another report after closing your 19188, https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19200. That's the same issue as this one I think. It's even the same with evaluating M-: (point) two times moving point out of the invisible text. |
I investigated a bit more. This issue is definitely caused by a bug in Emacs: line movement ends up at an invisible position, which should not happen. The relevant code is all in simple.el, AFAIK, moving out of invisible regions is all done from Lisp. That code is all very complex, and this bug is a bit exotic and doesn't happen very often, so I somewhat doubt it would be fixed soon, but who knows. Alternatively, we could try to make use of the new cursor-sensor.el package in Emacs 25. If I modify We could also use I have also a fix btw: in
with just
The problem is that I have no idea why this works and if it makes any sense... |
Hmm, Stefan meant it would best if we would use something like cursor-sensor. Would that be acceptable? The package itself will be only available for emacs 25. Here is a short demonstration how it works: in some buffer, e.g.
and then enable `cursor-intangible-mode' and move around. AFAICT this mode moves the cursor out of an intangible area in the same direction that point had been moved while running the last command, i.e. forward upto after the end when we came from before that area etc. |
Eli has joined the discussion and suggested to create another report. I'll do that, maybe he can help. |
It's bug#23079. |
Mmh, Stefan has closed the bug, but with good arguments. But apparently, if we would use the invisible text property instead of the invisible overlay property, the problem could be avoided by manipulating property stickinesses. |
Ah: "For overlays, you need to use the insertion-type of the beg/end marker. |
But because the behavior is reverse for overlays, we are already doing it correctly. But I've now found something interesting: |
Hmm, that's interesting. Removing just |
Noam Postavsky notifications@github.com writes:
Thanks! Then this is hopefully one of the last missing pieces of the This counts as changing the buffer, and changing the buffer in The highlighting glitch is expected AFAICT, because post-command-hook |
|
Ok, seems this is not easy to fix. Maybe consider a temporary workaround, like the following:
This repositions point based on a very simple heuristic that can sometimes guess wrong. At least, WYSIWYG, and highlighting works correctly. |
I could have told you that right from the start ;-) We have already invested a lot of time into this.
Since given the current implementation there only appear to be problems given certain unusual (for Magit buffers) settings, I don't intend to add any hacks to Magit. I think it is justified that we use text properties to highlight hunks but overlays for other sections because for hunks we would need way more than the usual one or two overlays. But I am somewhat surprised that this even matters when moving to a collapsed |
Please check whether moving a closing paren from the second to last line of |
Nope. I can't see why that should help though. modified lisp/magit-diff.el
@@ -1972,8 +1972,8 @@ (cl-defun magit-diff-paint-hunk
(if highlight 'magit-diff-removed-highlight 'magit-diff-removed))
(t
(if highlight 'magit-diff-context-highlight 'magit-diff-context))))
- (forward-line))))))
- (magit-diff-update-hunk-refinement section))
+ (forward-line)))))
+ (magit-diff-update-hunk-refinement section)))
(defun magit-diff-paint-whitespace (merging)
(when (and magit-diff-paint-whitespace
It only runs when the goal column is set to 0. It seems that |
Jonas Bernoulli notifications@github.com writes:
Here we have different opinions. I don't consider setting goal-column
Which would decrease performance, yes.
Agreed. |
Jonas Bernoulli notifications@github.com writes:
I tried with two parens, since moving one parent doesn't change the |
@michael-heerdegen In the past we have used similar hacks to what you are proposing here. They caused more issues than they solved. That's why I don't want to add your proposed mode to Magit. In the past we had many issues due to weird cursor positions, and when we fixed a new variation, then that usually caused breakage in other cases. Since "you" (i.e. everyone who sets Please install the kludge you proposed locally instead (well I suspect you already did that). |
Hello,
this is an annoying bug I see all the time I think when there are multiple lines of unstaged stuff in the status buffer. I doubt it's related to my setup, but please tell me should you not see this behavior.
I use
goal-column -> 0
, that triggers the bug often because it occurs only in the first column in the status buffer.Here is what I see: this is what my status buffer looks like:
Now I hit
[down]
(bound tonext-line
) two times to get to "iterators.el". This looks like this:There is no highlighted file or hunk to operate on, this already shows that there is something not kosher. Ok, I hit s to stage all changes in "iterators.el". I see this:
Obviously, I operated on a line different from the line where the cursor had been displayed.
Such problems are typical when using overlays making buffer parts invisible. Maybe there is an invisible newline character between point and the visible line, so that point is not located at the line where it seems to be, or something similar.
Thanks in advance,
Michael.
The text was updated successfully, but these errors were encountered: