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

PR: Shift maximum character edge line to match editor characters #16277

Merged
merged 1 commit into from
Aug 25, 2021
Merged

PR: Shift maximum character edge line to match editor characters #16277

merged 1 commit into from
Aug 25, 2021

Conversation

rhkarls
Copy link
Contributor

@rhkarls rhkarls commented Aug 25, 2021

Description of Changes

The vertical line indicating the maximum characters per line (edge line) is shifted 3 units to the right so that it aligns with the characters of the editor.

Current behavior:
Screenshot 2021-08-24 124732 - Copy

Shifting line to the right by 3 units:
Screenshot 2021-08-24 125010 - Copy

This is tested also for other font sizes (7-16) and works well, as well as other standard monospace fonts shipping with Windows.

Why shift by 3?
I tested with 3 first based on this being added to the line number margin

margin = 3+self.editor.fontMetrics().width('9'*digits)

And it works quite well, by chance I suppose. I also tried removing the 3 from the line number margin (without shifting edge line), but this has no effect.

An alternative solution which also appears to work quite well is to shift the line relative to the character width. Might be more robust for different (odd) fonts/resolutions. To keep this simple fix very simple I stuck with shifting 3 units as it appears to work well across sizes and fonts. Example shifting 1/3rd of a character width, an appropriate number is probably between 1/3 and 1/2.

char_width = self.editor.fontMetrics().width('9')
x = column * char_width + 0.33 * char_width

Issue(s) Resolved

Fixes #16248

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: Reinert Huseby Karlsen

@dalthviz dalthviz changed the title Shift maximum character edge line to match editor characters PR: Shift maximum character edge line to match editor characters Aug 25, 2021
@ccordoba12 ccordoba12 changed the base branch from master to 5.x August 25, 2021 13:30
@ccordoba12 ccordoba12 changed the base branch from 5.x to master August 25, 2021 13:30
@ccordoba12
Copy link
Member

Thanks a lot for your help @rhkarls! Please make your branch to derive from our 5.x branch (instead of master), with the following commands:

git checkout 5.x
git checkout shift-editor-edge-line
git rebase --onto 5.x master shift-editor-edge-line
git push -f origin shift-editor-edge-line

Otherwise looks good to me.

@ccordoba12 ccordoba12 added this to the v5.1.2 milestone Aug 25, 2021
@ccordoba12 ccordoba12 changed the base branch from master to 5.x August 25, 2021 13:46
@rhkarls
Copy link
Contributor Author

rhkarls commented Aug 25, 2021

Thanks a lot for your help @rhkarls! Please make your branch to derive from our 5.x branch (instead of master), with the following commands:

git checkout 5.x
git checkout shift-editor-edge-line
git rebase --onto 5.x master shift-editor-edge-line
git push -f origin shift-editor-edge-line

Otherwise looks good to me.

Cheers! Hope its good with the 5.x branch now - sorry I missed to checkout 5.x earlier

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rhkarls!

Note: The failures in our tests are unrelated to this.

@ccordoba12 ccordoba12 merged commit ef3daf5 into spyder-ide:5.x Aug 25, 2021
ccordoba12 added a commit that referenced this pull request Aug 25, 2021
@rhkarls rhkarls deleted the shift-editor-edge-line branch August 25, 2021 14:49
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.

Maximum character line slightly wrong
2 participants