Repository navigation
fix(indent): fix several indentation issues, conform to released version - #302
Conversation
Test cases for: * Leading pipes and ampersands in type union/inersections * Functions in object types * Function type with object paramer * Switch statement (issue HerringtonDarkholme#271)
The current release of [`indent/typescript.vim](https://github.com/vim/vim/blob/v9.1.2090/runtime/indent/typescript.vim) in the github.com/vim/vim repo includes some changes not in this repo. This version of `indent/typescript.vim` in this commit: * Is based on the release version * Fixes the test cases in the previous commit
test cases for single-line if, without a trailing semicolon.
fixes the test case in the previous commit
* make sure indentation doesn't waterfall in function type with object parameter * arrow function with multi-line args
fixes tests of previous commit
multiline generic types should indent
fixes test in previous commit
added comments #------------------ between each test case to make it easier to visually parse the file
fixes the test of the previous commit
There was a problem hiding this comment.
Pull request overview
This PR fixes several TypeScript indentation issues and conforms the local indent/typescript.vim to match the version released in Vim 9.1.2090. The PR replaces external yats# helper functions with inline implementations and adds comprehensive test coverage for the fixed indentation scenarios.
Changes:
- Added indentation fixes for TypeScript union/intersection types with leading pipes and ampersands
- Fixed indentation for switch/case statements, one-line if statements, arrow functions with multi-line arguments, and multiline generic types
- Replaced
yats#helper function calls with locals:implementations to align with the released Vim version - Added comprehensive test cases covering all the fixed indentation scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| test/indent.vader | Added 8 new test cases covering union types, object types with functions, function types with object parameters, switch statements, one-line if statements, arrow functions, and multiline generics |
| indent/typescript.vim | Synced with Vim 9.1.2090 release; replaced yats# helpers with local implementations; added new regex patterns and helper functions for TypeScript-specific features; implemented fixes for switch/case, one-line scope, union/intersection types, and generic type indentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if getline(a:lnum) =~ '^\s*[])}]\s*\%([;,:]\s*\)\=$' | ||
| return a:ind | ||
| endif | ||
|
|
There was a problem hiding this comment.
Trailing whitespace found. This line should not end with whitespace.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| if msl_txt =~ s:obj_prop_line && msl_txt =~ s:comma_last | ||
| return msl_ind | ||
| endif | ||
|
|
There was a problem hiding this comment.
Trailing whitespace found. This line should not end with whitespace.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
d1a00ce
into
HerringtonDarkholme:master
Hi,
This PR updates
indent/typescript.vimwith fixes for #271 and a handful of other indentation problems that have been nagging me. I added test cases for them intest/indent.vaderI started with the version released in the latest
/Applications/MacVim.app/Contents/Resources/vim/runtime/indent/typescript.vim, but coming to this repo I saw that the version here had a few differences:indent/typescript.vimuses someyats#helpers instead of including them inlines:continuation_regex,s:ternary, ands:ternary_qdifferSince my version is based on the release, this PR conforms
indent/typescript.vimto the release, plus adds the fixes. I hope that's OK!PS. I came to this with little knowledge of vim scripting nor how vim indent scripts work; had AI do the coding for me 🙄