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

Auto detect tab/indentation width, insert tab as spaces #311

Closed
zufuliu opened this issue Apr 8, 2021 · 8 comments
Closed

Auto detect tab/indentation width, insert tab as spaces #311

zufuliu opened this issue Apr 8, 2021 · 8 comments
Labels
✅enhancement 🌐i18n Localization/Internationalization
Milestone

Comments

@zufuliu
Copy link
Owner

zufuliu commented Apr 8, 2021

Issue #299 implemented global, scheme and file levels tab settings, however, tab settings for current file (by default inherited from scheme or global settings) will confusing people when they not match the actually file. It's worthy to implement some sort of auto detection to reduce the confusing.

SciTE has a 50 lines detection method (SciTEBase::DiscoverIndentSetting() in SciTEIO.cxx), we can port it to Notepad2 with one change: drop support for tab width = 1, which is need to reliable detect Java code contains document comments (where the space before * is alignment space).

@zufuliu zufuliu added this to the v4.21.05 milestone Apr 8, 2021
zufuliu added a commit that referenced this issue Apr 9, 2021
@zufuliu zufuliu added the 🌐i18n Localization/Internationalization label Apr 9, 2021
@zufuliu
Copy link
Owner Author

zufuliu commented Apr 22, 2021

Implemented by f16ca83. The Tab Settings dialog needs translation.

@lifenjoiner
Copy link
Contributor

There is an issue on diff/patch files:
TabsWidth-Auto-on-Patch

@zufuliu
Copy link
Owner Author

zufuliu commented Apr 25, 2021

Indentation width is set to be same as tab width, so I think this is detected.

@zufuliu
Copy link
Owner Author

zufuliu commented Apr 25, 2021

It's might better to ignore detected tab/indentation width for binary file and diff file (them don't need to be detected), the result doesn't not make any sense:

  1. Binary is loaded in read only mode (locked for editing).
  2. In diff file, line starts with non-space character has specially meaning.

@lifenjoiner
Copy link
Contributor

Yes, it is detected. But looks ... not good ...
What about making some exceptions (ignore detection) by scheme?

@lifenjoiner
Copy link
Contributor

A draft/PoC lifenjoiner@303c4f2 calling FileVars_Apply(&fvCurFile) 1 more time

@lifenjoiner
Copy link
Contributor

It is reasonable that:
fvCurFile is prepared and applied while loading file,
and EditDetectIndentation is a part of that;
also detecting/applying lexer after file loaded.

So, reset the inappropriate auto detected indentation results is reasonable, acting like manual.
Even if doing EditDetectIndentation after file loaded, it also requires 1 more calling of FileVars_Apply(&fvCurFile).

@zufuliu
Copy link
Owner Author

zufuliu commented Apr 26, 2021

Binary file and diff file fixed by e64d89d.

@zufuliu zufuliu closed this as completed May 13, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅enhancement 🌐i18n Localization/Internationalization
Projects
None yet
Development

No branches or pull requests

2 participants