ZIm/crates/language/src
Smit Barmase d09c7eb317
language: Add context-aware decrease indent for Python (#33370)
Closes #33238, follow-up to
https://github.com/zed-industries/zed/pull/29625.

Changes:

- Removed `significant_indentation`, which was the way to introduce
indentation scoping in languages like Python. However, it turned out to
be unnecessarily complicated to define and maintain.
- Introduced `decrease_indent_patterns`, which takes a `pattern` keyword
to automatically outdent and `valid_after` keywords to treat as valid
code points to snap to. The outdent happens to the most recent
`valid_after` keyword that also has less or equal indentation than the
currently typed keyword.

Fixes:

1. In Python, typing `except`, `finally`, `else`, and so on now
automatically indents intelligently based on the context in which it
appears. For instance:

```py
try:
    if a == 1:
        try:
             b = 2
             ^  # <-- typing "except:" here would indent it to inner try block
```

but,

```py
try:
    if a == 1:
        try:
             b = 2
    ^  # <-- typing "except:" here would indent it to outer try block
```

2. Fixes comments not maintaining indent.

Release Notes:

- Improved auto outdent for Python while typing keywords like `except`,
`else`, `finally`, etc.
- Fixed the issue where comments in Python would not maintain their
indentation.
2025-06-26 11:11:03 +05:30
..
syntax_map Add a test demonstrating ERB language loading bug (#32278) 2025-06-11 04:03:42 +00:00
buffer.rs language: Add context-aware decrease indent for Python (#33370) 2025-06-26 11:11:03 +05:30
buffer_tests.rs Add #[track_caller] to test utilities that involve marked text (#32043) 2025-06-04 02:37:27 +00:00
diagnostic_set.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
highlight_map.rs Docs for indent_size_for_line and co 2024-01-09 20:50:34 +01:00
language.rs language: Add context-aware decrease indent for Python (#33370) 2025-06-26 11:11:03 +05:30
language_registry.rs Add language server control tool into the status bar (#32490) 2025-06-25 19:57:28 +03:00
language_settings.rs copilot: Allow enterprise to sign in and use copilot (#32296) 2025-06-17 11:36:53 +02:00
manifest.rs python: Re-land usage of source file path in toolchain picker (#31893) 2025-06-02 16:29:06 +00:00
outline.rs editor: Improve code completion filtering to provide fewer and more accurate suggestions (#32928) 2025-06-18 16:01:28 +05:30
proto.rs Show inline previews for LSP document colors (#32816) 2025-06-17 13:46:21 +00:00
syntax_map.rs Diff view (#32922) 2025-06-18 14:43:23 +00:00
task_context.rs Add initial package.json scripts task autodetection (#32497) 2025-06-10 22:16:27 +00:00
text_diff.rs agent: Improve Gemini support in the edit_file tool (#31116) 2025-05-22 12:01:43 +03:00
toolchain.rs python: Re-land usage of source file path in toolchain picker (#31893) 2025-06-02 16:29:06 +00:00