Do not assume that the default margin widths are zero #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey Paul, when setting/resetting margin widths Olivetti currently assumes that the default values of
left-margin-widthandright-margin-widthare zero. This assumption was partly removed after #78 in 1690a3c, but we forgot to account for the two other places where the same assumption is made. Those places result in more subtle bugs than the previous one, so I've only recently noticed a problem. When the current window is not wide enough and Olivetti is active (not necessarily in the current window), margins are set to zero instead of their default values. This PR fixes that.EDIT 1: I apparently forgot the mistake I made in #78 and incorporated the same change here. I'll try to see how to calculate the additional width correctly without assuming that
olivetti-reset-windowsets the margin widths to zero.EDIT 2: I've changed the functions
olivetti-normalize-widthandolivetti-set-windowto compute the window's width in pixels by taking the margins into account. If the default margin widths are zero, nothing changes from before; otherwise, margins are treated as if they are part of the window's text area (while fringes, vertical dividers, or scroll bars are still excluded). In my testing this results in the same behavior as before while also respecting the default margin widths.