moe icon indicating copy to clipboard operation
moe copied to clipboard

Indicate modified lines

Open tobimensch opened this issue 3 years ago • 4 comments

At a later stage it will make sense for moe to add a complex diff feature, like vim has, to compare two files or two states of the same file side-by-side.

Until then I think something simpler, that's easier to implement, but still helpful to users, would be nice.

So, a indicateModifiedLines or similarly named feature should exist, where the line numbers to the left are underlined or in some other way stylized to indicate that something has happened.

Pseudo example:

1 First line 2 Second line 3 Third line 4 Fouth line

Here I used a bold font (I think underlining would work better in a terminal, but I think we'd have to experiment with that) to indicate that lines 2 and 3 were in some way modified/tampered with, or were not part of the previous state (the one which is on disk, or the one that is in git).

tobimensch avatar Jul 10 '20 18:07 tobimensch

@fox0430 @tobimensch

My idea would be use other colours for the respective line numbers, inspired by how VS Code / VSCodium and related editors handle this feature. There, new lines receive a green flag next to their line number and edited lines get a blue one analogously. Deleted lines are indicated by little red triangles between the remaining line numbers in the line number flag column.

To bring this feature to Moe, I would like to suggest to change the background colour of the line number to either green (new) or blue (modified) while the foreground colour stays the same. For deleted lines, the foreground colour of the line number might change to red while the background is left unchanged. The line number writing routine to me looks like changing the colours would be easier than switching to bold or underlined style: https://github.com/fox0430/moe/blob/develop/src/moepkg/editorview.nim#L184.

This is just an initial idea for a more concrete implementation for discussion and I would appreciate your comments.

kevinmatthes avatar Jan 31 '23 20:01 kevinmatthes

@kevinmatthes

I think it seems a good idea about ui. I was thinking of adding support as git support, Can this feature be used on VS Code without using git?

fox0430 avatar Feb 01 '23 21:02 fox0430

@fox0430

VS Code itself only supports this feature if the edited file is tracked by Git. For inspiration, I would like to suggest the editor Kate, KDE's default GUI text editor. It uses (almost) the same colour flag approach to indicate lines which are edited during the current session (orange flag: unsaved edit; green flag: saved edit) and works for all files without the need to be tracked by Git.

I was thinking about some approaches to track whether a line was edited at all to start with the "edited line" flag; maybe this could be realised in combination with the line number calculation?

kevinmatthes avatar Feb 02 '23 17:02 kevinmatthes

@kevinmatthes

Okay, We will support this feature separately from git support.

fox0430 avatar Feb 02 '23 20:02 fox0430