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

Unable to strip trailing spaces for custom file types using Diff lexer #2041

Closed
cristicc opened this issue Jan 9, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@cristicc
Copy link
Contributor

commented Jan 9, 2019

Hi,

I'm currently using a custom file type configuration where I enabled the DIFF lexer which provides the best highlighting experience for this particular file syntax:

[styling=Diff]
comment=default

[settings]
lexer_filetype=Diff

Unfortunately, there is a highly demanded editor feature that cannot be used in this context: stripping trailing spaces.

By inspecting the source code, it's quite obvious the limitation is imposed by the DIFF lexer:

void editor_strip_line_trailing_spaces(GeanyEditor *editor, gint line)
{
       [...]
	/* Diff hunks should keep trailing spaces */
	if (sci_get_lexer(editor->sci) == SCLEX_DIFF)
		return;
       [...]
}

I'm not sure if this is a bug or just a simple workaround to prevent corruptions of the .patch files.
I just want to use the DIFF syntax highlighting on files that do not have anything in common with the patch files, in particular by having the option to strip trailing spaces enabled permanently.

Does it make sense to improve the implementation by checking for DIFF file type instead of DIFF lexer?

Thank you!

@codebrainz

This comment has been minimized.

Copy link
Member

commented Jan 9, 2019

Does it make sense to improve the implementation by checking for DIFF file type instead of DIFF lexer?

👍

@codebrainz codebrainz added the filetype label Jan 9, 2019

@b4n

This comment has been minimized.

Copy link
Member

commented Jan 9, 2019

As @codebrainz thumbed up, changing the detection logic to using the filetype sounds good.

@cristicc

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2019

Thanks for your quick feedback!
Please see the PR, tested and working as expected..

@b4n b4n self-assigned this Jan 10, 2019

@b4n b4n added this to the 1.35 milestone Jan 10, 2019

@b4n b4n closed this in #2043 Jan 10, 2019

b4n added a commit that referenced this issue Jan 10, 2019

Merge pull request #2043 from cristicc/feature/diff-lexer-fix
Fix stripping trailing spaces for custom file types using the DIFF lexer.

Fixes #2041.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.