Skip to content
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

Configurable EOL offset #104

Open
lougreenwood opened this issue Oct 3, 2023 · 2 comments
Open

Configurable EOL offset #104

lougreenwood opened this issue Oct 3, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@lougreenwood
Copy link

lougreenwood commented Oct 3, 2023

Currently the EOL offset for the message template or not committed template requires prepending with spaces, additionally the virtual_text_column will default to the EOL when the line is longer than this setting.

However, the need to prepend spaces is both visually messy and adds a (small, but not invisible) layer of maintenance cost now that there are multiple templates. It also requires overriding the default templates even if the only thing a user wants to configure is the offset.

Did you consider adding something like an eol_offset config to allow something like

      message_template = "<author>, <date> • <summary>",
      message_when_not_committed = "<author>, <date> • Uncommitted changes",
      eol_offset = 5, -- offset the message by 5 cols from the EOL
      virtual_text_column = 40,

So that all messages are consistently offset by 5 cols from the end of the line and messages.

@f-person
Copy link
Owner

f-person commented Oct 3, 2023

Hi! I never considered this since we had a single template until recently, but I see how this could be useful.

additionally the virtual_text_column will default to the EOL when the line is longer than this setting.

Are you suggesting changing the behavior with the introduction of eol_offset somehow?

@f-person f-person added the enhancement New feature or request label Oct 3, 2023
@lougreenwood
Copy link
Author

Hi! I never considered this since we had a single template until recently, but I see how this could be useful.

Yep, I figured it would be something like this 😄 👍.

Are you suggesting changing the behavior with the introduction of eol_offset somehow?

Not necessarily in a breaking way, only that virtual_text_column will also use the eol_offset value if the line length is longer than the virtual_text_column.

Or thinking about this some more, just always use eol_offset value with virtual_text_column, but internally we'd calculate the effective virtual_text_column as virtual_text_column -= eol_offset so that if say a line is 99 chars long and the user-defined virtual_text_column = 100 we still get an eol_offset of +5 from end of the line (so starting at col 104 - essentially ensuring that all places where the templates have a minimum offset of what is defined by eol_offset).

Something like:

-- line_length = 99
-- eol_offset = 5
-- virtual_text_column = 100

virtual_text_column -= eol_offset
local template_column = nil
if virtual_text_column > line_length

  -- if the line length was 50, then we'd render the template at col 100 ((100 - 5) + 5), matching the user defined value.
  return virtual_text_column + eol_offset
else
  -- if the line length is 99, then we'd render the template at col 104 (99 + 5)
  return line_length + eol_offset
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants