diff options
Diffstat (limited to 'src/debputy/linting/lint_impl.py')
-rw-r--r-- | src/debputy/linting/lint_impl.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/debputy/linting/lint_impl.py b/src/debputy/linting/lint_impl.py index 66ff635..058b784 100644 --- a/src/debputy/linting/lint_impl.py +++ b/src/debputy/linting/lint_impl.py @@ -27,6 +27,7 @@ from debputy.lsp.lsp_debian_control import _lint_debian_control from debputy.lsp.lsp_debian_copyright import _lint_debian_copyright from debputy.lsp.lsp_debian_debputy_manifest import _lint_debian_debputy_manifest from debputy.lsp.lsp_debian_rules import _lint_debian_rules_impl +from debputy.lsp.lsp_debian_tests_control import _lint_debian_tests_control from debputy.lsp.quickfixes import provide_standard_quickfixes_from_diagnostics from debputy.lsp.spellchecking import disable_spellchecking from debputy.lsp.text_edit import ( @@ -37,11 +38,12 @@ from debputy.lsp.text_edit import ( from debputy.util import _warn, _error, _info LINTER_FORMATS = { + "debian/changelog": _lint_debian_changelog, "debian/control": _lint_debian_control, "debian/copyright": _lint_debian_copyright, - "debian/changelog": _lint_debian_changelog, - "debian/rules": _lint_debian_rules_impl, "debian/debputy.manifest": _lint_debian_debputy_manifest, + "debian/rules": _lint_debian_rules_impl, + "debian/tests/control": _lint_debian_tests_control, } @@ -110,6 +112,18 @@ def perform_linting_of_file( _diagnostics_run(fo, filename, text, handler, lint_report) +def _edit_happens_before_last_fix( + last_edit_pos: Position, + last_fix_position: Position, +) -> bool: + if last_edit_pos.line < last_fix_position.line: + return True + return ( + last_edit_pos.line == last_fix_position.character + and last_edit_pos.character < last_fix_position.character + ) + + def _auto_fix_run( fo: OutputStylingBase, filename: str, @@ -152,12 +166,8 @@ def _auto_fix_run( ) last_edit = sorted_edits[-1] last_edit_pos = last_edit.range.start - if ( - last_edit_pos.line <= last_fix_position.line - or last_edit_pos.character < last_fix_position.character - ): + if _edit_happens_before_last_fix(last_edit_pos, last_fix_position): if not another_round: - if remaining_rounds > 0: remaining_rounds -= 1 print( @@ -172,10 +182,11 @@ def _auto_fix_run( continue edits.extend(sorted_edits) fixed_diagnostics.append(diagnostic) + last_fix_position = sorted_edits[-1].range.start if another_round and not edits: _error( - "Internal error: Detected an overlapping edit and yet had edits to perform..." + "Internal error: Detected an overlapping edit and yet had no edits to perform..." ) fixed_count += len(fixed_diagnostics) |