Skip to content

Conversation

@blamedrop
Copy link
Contributor

Right now it has No name like every other new file.

@blamedrop blamedrop changed the title Add buffer name for raw pane Add buffer name for raw pane event viewer Jun 30, 2025
@blamedrop
Copy link
Contributor Author

@dmaluka can you approve the workflow?

1 workflow awaiting approval

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 5, 2025

I don't know what is "workflow approval", but I can merge this PR right away, unless @JoeKar or anyone else has any objections.

@JoeKar
Copy link
Member

JoeKar commented Jul 5, 2025 via email

@blamedrop
Copy link
Contributor Author

isn‘t that bad and it be somehow „consistent“

But as I found out and reported in #3791 (comment) (ab)using fake path to provide name for "virtual" buffers also have some issues attached 🤷‍♂️

@cutelisp
Copy link
Contributor

cutelisp commented Jul 6, 2025

@JoeKar isn‘t that bad and it be somehow „consistent

Turns out my suggestion can lead to sketchy events #3791 (comment). So I agree with @blamedrop it's seems better to use SetName instead of a hacky fake path.

If this SetName approach gets accepted here, we can still be consistent by changing existent similar buffer creations. e.g. https://github.com/zyedidia/micro/blob/41b912b5392ff80c1cce7d0ef7668f406977cc00/internal/action/globals.go#L14

@JoeKar
Copy link
Member

JoeKar commented Jul 6, 2025 via email

Using such fake path have some issues as mentioned in micro-editor#3791 (comment) comment
@blamedrop
Copy link
Contributor Author

Ok…overread that example. So we should fix the log case with a second commit here too and then it can be merged.

Done!

@JoeKar
Copy link
Member

JoeKar commented Jul 6, 2025 via email

@blamedrop
Copy link
Contributor Author

Shall we adapt the info buffer as well?

WDYM? This one?

ib.Buffer = buffer.NewBufferFromString("", "", buffer.BTInfo)

It doesn't have 'fake path'. Would setting its name have any visible effect anywhere?

@cutelisp
Copy link
Contributor

cutelisp commented Jul 6, 2025

Done!

LGTM

Would setting its name have any visible effect anywhere?

Don't think so, not sure why would we add a name to it

@JoeKar
Copy link
Member

JoeKar commented Jul 6, 2025 via email

@cutelisp
Copy link
Contributor

cutelisp commented Jul 6, 2025

It doesn't hurt at all 🤕. I just said it because I don't think we were using the name anywhere. We can do it for a matter of consistency 👍.

@blamedrop
Copy link
Contributor Author

Right, good idea, having it named could be useful in debugging/logging. I'll do it later.

By the way, since we're discussing it here quite extensively, what do you think about refactoring NewBufferFromString("", "", bufferType) + SetName(bufferName) to a method for these?

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 6, 2025

it looks like providing it a fake path might be kinda buggy - trying to open real file named Log or possibly it's backup (haven't checked that tho). <...>

Indeed. This is problematic even just because it prevents us from opening a real file named Log. Thanks for fixing that as well.

Might not be the most obvious use case, but printing the name of the buffer within the log could help somewhere.

I'm not sure that would be very useful (if the point is to distinguish the infobuffer from other buffers, there are other ways to do that, e.g. print its Type, which should be BTInfo). And, the description of the name field says: // Name of the buffer on the status line.

But, yeah, it wouldn't hurt to do that, e.g.:

--- a/internal/info/infobuffer.go
+++ b/internal/info/infobuffer.go
@@ -46,6 +46,9 @@ func NewBuffer() *InfoBuf {
 	ib.Buffer = buffer.NewBufferFromString("", "", buffer.BTInfo)
 	ib.LoadHistory()
 
+	// this name isn't really displayed anywhere, set it just for debugging purposes
+	ib.SetName("Info buffer")
+
 	return ib
 }
 

Anyway, I think this PR is good to merge as is.

what do you think about refactoring NewBufferFromString("", "", bufferType) + SetName(bufferName) to a method for these?

IMHO that would be an overkill.

@blamedrop
Copy link
Contributor Author

Okay, thanks. Feel free to merge it then.

@JoeKar
Copy link
Member

JoeKar commented Jul 6, 2025 via email

@blamedrop
Copy link
Contributor Author

@dmaluka could you merge it?

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 8, 2025

Could you rebase, to remove this merge commit: cad445e ?

@blamedrop
Copy link
Contributor Author

Could you rebase, to remove this merge commit: cad445e ?

Uh, not really, I'm AFK, sorry.

Don't you prefer squash merging anyway? It won't include that merge branch commit IIRC.

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 8, 2025

Uh, not really, I'm AFK, sorry.

Well, it isn't urgent, is it? ;)

Don't you prefer squash merging anyway? It won't include that merge branch commit IIRC.

You have two independent changes in two separate commits, so it would be nice to keep them separate in the git history.

I only prefer squashing in cases when the commit history in the PR is a mess (and the author is too clueless to clean it up).

@dmaluka dmaluka merged commit 55a5530 into micro-editor:master Jul 8, 2025
@dmaluka
Copy link
Collaborator

dmaluka commented Jul 8, 2025

Ok, just tried "Rebase and merge" and it seems to work. Done. :)

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 8, 2025

Although AFAICS the downside of "Rebase and merge" is that there is no PR number added in any of the commit messages. (Looks like Github in its wisdom adds it only if either there is just one commit or there is a merge commit, not if there are 2 or more commits rebased without a merge commit.)

@blamedrop blamedrop deleted the raw-pane branch July 8, 2025 23:18
@blamedrop
Copy link
Contributor Author

Thank you!

Although AFAICS the downside of "Rebase and merge" is that there is no PR number added in any of the commit messages. (Looks like Github in its wisdom adds it only if either there is just one commit or there is a merge commit, not if there are 2 or more commits rebased without a merge commit.)

True, that's unfortunate.
Although it keeps reference to relevant PR somewhere anyway - you can see it in the commit details:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants