Komodo / KomodoEdit

Komodo Edit is a fast and free multi-language code editor. Written in JS, Python, C++ and based on the Mozilla platform.
http://www.komodoide.com/komodo-edit
Other
2.16k stars 303 forks source link

Current file preferences > Editor > Indentation tabs/spaces not set on file load #1142

Open brianjcohen opened 8 years ago

brianjcohen commented 8 years ago

Short Summary

The settings dialog 'Current file preferences > Editor > Indentation' does not accurately reflect the tab/spaces settings of the current file.

Steps to Reproduce

  1. Open a file that was created with indentations consisting of 2 spaces each.
  2. Click Edit > Current File Preferences > Editor > Indentation.

    Expected results

I expect these settings to reflect the state of the file.

Actual results

Settings in this pane appear to match their global settings counterparts, even if they are different.

It's still possible to use the Current File Preferences pane to modify existing indentations but only if you FIRST change it to something else, and THEN change it to what you want it to be (assuming that what you want it to be matches your global defaults. otherwise the extra step is unnecessary).

Note that when clicking 'Apply' in this pane, the 'Places' pane clears per my earlier Issue report: https://github.com/Komodo/KomodoEdit/issues/328

Platform Information

Komodo Edit or IDE? Edit Komodo Version? version 9.3.2, build 16460, platform linux-x86_64. Built on Thu Dec 10 19:37:22 2015 Operating System (and version)? Ubuntu Linux 14.04 LTS

Additional Information

-- eg. Error logs, screenshots, workarounds --

mitchell-as commented 8 years ago

I'm having trouble understanding what you mean by your first step. Are you creating this file outside of Komodo? Or did you create the file inside Komodo and manually insert two spaces for indentation (while keeping global indentation at 4) and then reopen it? I'm not certain that Komodo tries to auto-detect indentation in a file (at first glance it seems very error prone to me).

For my part I've opened a fresh instance of Komodo, created a new file, inserted two spaces for indentation and typed some text, saved the file, reopened it, and noted that my file preferences for indentation remains the default 4. I've also created a file outside Komodo with two-space indentation and loaded it into Komodo for the first time. File preferences still say 4 spaces for indentation.

th3coop commented 8 years ago

I expect these settings to reflect the state of the file.

You need to enable Preferences > Editor > Indentation > Allow file contents to override Tab and Indentation settings. File level inherits from the global level until you set the file level pref. That's by design.

We don't force file preferences. Since file level preferences override any other level of preferences in the pref hierarchy (Globe < Project < Lang Specific < File) and most people/teams would want a project wide indentation configuration, it would be unwise (in my mind) to force prefs to set to each files different detected settings.

This would be @Naatan's call I think. Should we have an option to allow file level prefs to be set on file load?

SleepyJay commented 8 years ago

The issue as I see it is that I have legacy files that were not written by me, and certainly not written in Komodo. They apparently also predate any consistent use of indentation (or of anything consistent, really).

Often times when I open these files, for no reason that I can tell, they will be indented 2 spaces, even though, AFAIK, the global, language, AND file prefs ALL say 4 spaces. Changing this for this particular file eventually works, but I don't know the exact voodoo I have to do to make it actually happen. It is super annoying.

I believe the OP is saying the same thing I am: the file prefs don't seem to represent anything when un-changed and the ACTUAL settings are simply a mystery for some files.

It seems to me what you want is to unify these settings better so that you can see the result of the overrides. That's probably a lot more work than you want to put in, though. :)

At least have a way to FORCE the file to behave the way that the settings are actually configured.

brianjcohen commented 8 years ago

Yes, @SleepyJay that is correct. I have it also on my todo list to do a screencast showing how it behaved in Komodo 8 and how it regressed in Komodo 9. Just haven't gotten around to it yet.

SleepyJay commented 8 years ago

Glad we're on the same page. ;)

BTW, I just did the correct voodoo: change to 8 spaces in file prefs, apply, confirm by pressing tab in file, change back to 4, apply, and confirm. The silly legacy code still has indentation issues, but at least the editor is working WITH me now.

brianjcohen commented 8 years ago

@SleepyJay yes I think what you've done matches what I wrote in my original post: It's still possible to use the Current File Preferences pane to modify existing indentations but only if you FIRST change it to something else, and THEN change it to what you want it to be (assuming that what you want it to be matches your global defaults. otherwise the extra step is unnecessary).

Naatan commented 8 years ago

This is because you have not explicitly set the indentation preferences. This dialog shows your current pref value, if it's not set it falls back on the global value.

What we need to do is make it evident that the values shown are implicit.

brianjcohen commented 8 years ago

@Naatan You are correct that we have not explicitly set the indentation preferences. What we're trying to say is that in Komodo 8, the per-file indentation pane appeared to behave differently. In Komodo 8, if you raised that dialog while editing a file that was (for example) created by someone else in a different editor, Komodo would (apparently) somehow detect the indentation scheme of that file and fill those values in. If you then changed those values and saved them, it would adjust the indentations across the whole file.

I suppose it's possible I'm wrong about Komodo Edit 8 "detecting" the indentation scheme but I don't think I am, because my global prefs under Komodo Edit 8 were 4/4 and if I opened a "foreign" file and raised the per-file Indentation prefs dialog I would see 2/2 filled in, suggesting that it was not (as you say) falling back on the global prefs because none had been set.

Naatan commented 8 years ago

That's correct, it did behave differently in Komodo 8. In Komodo 8 your current file preferences would be actively modified by the "Allow file to override .. " setting. This was deemed a bad user experience as preferences YOU set were being overwritten where there was really no need to. As of Komodo 9 Komodo will only override your setting on a per-session basis and will not save this to your preferences.

What you're seeing is fallout from this change.

brianjcohen commented 8 years ago

@Naatan when you say "fallout from this change", can you clarify whether you agree there is a defect here?

You said "... as preferences YOU set were being overwritten", but when the file was not created locally from within Komodo Edit, there is no "my current file preference", there's only the indentation scheme of the file as-is. I believe I should be possible for me to elect to modify the indentation scheme of that file easily. Komodo 8 let me do that easily. In Komodo 9 you have to jump through hoops: the Current File Preferences page won't modify the current file unless the values have changed.

Let's say the current file is 4/2 and your target is 4/4. You load up the file, you click into Current File Preferences and you see the global defaults, which are 4/4 in this case. Clicking OK or Apply will do nothing because nothing has changed. I could change it to, say, 4/8, click Apply, and THEN change it back to 4/4 and this time it will register the change and modify the file.

As an aside, clicking Apply that first time will clear the Places pane, per an earlier issue I reported a while back, #328 .

Naatan commented 8 years ago

I agree there is a defect here.

th3coop commented 7 years ago

@fulldump, please open a new ticket. This ticket is not about Tabs not working.