ZIm/crates/languages/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
..
bash Fix aggressive indent in shell scripts (#31973) 2025-06-03 10:50:58 -04:00
c editor: Add astrick on new line in multiline comment for Go, Rust, C, and C++ (#30808) 2025-05-16 15:30:04 +05:30
cpp editor: Add astrick on new line in multiline comment for Go, Rust, C, and C++ (#30808) 2025-05-16 15:30:04 +05:30
css Improve CSS syntax highlighting (#25326) 2025-06-06 17:14:32 -04:00
diff Improve diff syntax highlighting queries (#21740) 2024-12-12 15:18:36 -08:00
gitcommit Fix syntax highlighting of git commit messages (#26988) 2025-03-18 18:18:56 +00:00
go debugger: Generate inline values based on debugger.scm file (#33081) 2025-06-24 18:24:43 +00:00
gomod Add "tool" support to go.mod (#22995) 2025-01-15 17:44:28 +02:00
gowork File context for assistant panel (#9712) 2024-03-29 13:55:01 -07:00
javascript Allow identifiers in TypeScript/JavaScript test names (#32467) 2025-06-10 18:00:42 +02:00
jsdoc Add JSDoc scope (#29476) 2025-06-06 08:31:59 -04:00
json debugger: Run debug scenarios from package.json (#32958) 2025-06-18 20:04:25 +02:00
jsonc Treat bun.lock as JSONC (#27359) 2025-03-24 09:46:23 -04:00
markdown Add completion_query_characters in language (#27175) 2025-03-20 16:45:35 +05:30
markdown-inline Hide Markdown-Inline language from users with a new 'hidden' flag on language configs (#17104) 2024-08-29 11:23:33 -07:00
python language: Add context-aware decrease indent for Python (#33370) 2025-06-26 11:11:03 +05:30
regex Improve Regex highlighting (#28183) 2025-04-18 12:44:13 -04:00
rust debugger: Generate inline values based on debugger.scm file (#33081) 2025-06-24 18:24:43 +00:00
tsx Apply TypeScript test improvements to tsx files (#32477) 2025-06-11 20:23:16 +02:00
typescript editor: Adjust scope for prefer label for snippet workaround (#32515) 2025-06-11 10:38:39 +05:30
yaml vim: Update anyquotes and anybrackets to behave like mini.ai plugin (#24167) 2025-02-17 14:55:48 -07:00
bash.rs Fix aggressive indent in shell scripts (#31973) 2025-06-03 10:50:58 -04:00
c.rs editor: Utilize filter_text from language server for filter_range (#33155) 2025-06-21 19:47:16 +05:30
css.rs Use read-only access methods for read-only entity operations (#31479) 2025-05-26 23:04:31 -04:00
go.rs editor: Utilize filter_text from language server for filter_range (#33155) 2025-06-21 19:47:16 +05:30
json.rs debugger: Fix issues with debugging scripts from package.json (#32995) 2025-06-19 14:33:24 +00:00
lib.rs debugger: Fix issues with debugging scripts from package.json (#32995) 2025-06-19 14:33:24 +00:00
package_json.rs debugger: Fix issues with debugging scripts from package.json (#32995) 2025-06-19 14:33:24 +00:00
python.rs language: Add context-aware decrease indent for Python (#33370) 2025-06-26 11:11:03 +05:30
rust.rs editor: Utilize filter_text from language server for filter_range (#33155) 2025-06-21 19:47:16 +05:30
tailwind.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
typescript.rs editor: Utilize filter_text from language server for filter_range (#33155) 2025-06-21 19:47:16 +05:30
vtsls.rs editor: Utilize filter_text from language server for filter_range (#33155) 2025-06-21 19:47:16 +05:30
yaml.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00