mate-desktop / pluma

A powerful text editor for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
157 stars 65 forks source link

Tab-size is displayed wrong when open a file where tabs are used #583

Closed raveit65 closed 3 years ago

raveit65 commented 3 years ago

Expected behaviour

Tab-size is displayed correctly when open a file where tabs are used

Actual behaviour

Tab-size is displayed wrong when open a file where tabs are used

Steps to reproduce the behaviour

  1. open eg. cpufreq-prefs.c from master, It use tab-size=8 pluma-tabs-size-wrong

  2. reset tab-size in preferences (eg. 8 to 9 and back to 8) pluma-tabs-size-correct Et voila, tab-size is displayed correctly and all code lines are aligned. This can really cause issues when reviewing PRs and people are using pluma as editor.

MATE general version

= 1.25.x (master)

Package version

= 1.25.x (master)

Linux Distribution

Fedora and probably all others.

Link to downstream report of your Distribution

1.26 isn't released and i don't file out reports against myself :P

raveit65 commented 3 years ago

@rbuj @mbkma @mate-desktop/core-team Can you please take a look at it? I am not really sure when this regression was introduced but i noticed this a first time during 1.25 development. Maybe when we merged the show-tabs and show-spaces feature?

mbkma commented 3 years ago

I think it was introduced in commit 2edb465b646f671f3372c70f020bd3d3076e86ad. I will have a look what is wrong there. Edit: okay, no, sorry, I can not reproduce the issue.

rbuj commented 3 years ago

Setting the tab width works correctly, setting a new value may cause to lose indent when using a monospaced font. For example, if the tab width is 8 spaces and you change it to 4, you will need to add twice as many tabs to align the text. Screenshot at 2020-10-28 19-18-32

raveit65 commented 3 years ago

Yes, re-setting the tab-size works well. But when pluma is closed and tab-size is set to 8, than opening the file caused the wrong alignment of the lines. So, actual we're working with a wrong tab-size, if you don't know that a reset is needed.

raveit65 commented 3 years ago

Edit: okay, no, sorry, I can not reproduce the issue.

Hmm, ok, i will try to bisect pluma

mbkma commented 3 years ago

@raveit65 which font do you use?

raveit65 commented 3 years ago

It is monospace 10 Bildschirmfoto zu 2020-10-28 20-22-21

But maybe it is a problem with a underlying package in fedora 32. With an older (not updated) f31 VM and pluma-1.24.0 i can't reproduce the issue. I am actual updating the VM to latest package database from official fedora repos, and Mate is using the same package versions in all fedora versions. So let see what happens after the update.

Edit: pluma-1.24.1 in updated f31 VM doesn't have the issue. But same version in f32 on baremetal does have the issue :/ Ok, i will test more later....

rbuj commented 3 years ago

We can store the tab width for each file in gvfs metadata as we're doing with language and other attributes.

$ LANG=C gio info --attributes=metadata:: mate-applets/cpufreq/src/cpufreq-prefs.c 
uri: file:///home/robert/backup/mate-applets/cpufreq/src/cpufreq-prefs.c
local path: /home/robert/backup/mate-applets/cpufreq/src/cpufreq-prefs.c
unix mount: /dev/sda2[/home] /home btrfs rw,relatime,seclabel,ssd,space_cache,subvolid=256,subvol=/home
attributes:
  metadata::annotation: 
  metadata::pluma-language: c
  metadata::pluma-position: 1960
mbkma commented 3 years ago

Don't know if it would fix this problem, but adding modelines like /* ex:set ts=8 noet: */ may also help.

raveit65 commented 3 years ago

I found the problem. DPI was set to 180 inch and not to 192 inch for HIDPI like it should in font settings of m-c-c. So, this is definitely my own problem and caused by myself. Sorry for that noise :/