Skip to content

Support for multiline indentation#245

Merged
lhecker merged 9 commits into
microsoft:mainfrom
liltrendi:feat/tab-should-indent-highlighted-text
Jun 24, 2025
Merged

Support for multiline indentation#245
lhecker merged 9 commits into
microsoft:mainfrom
liltrendi:feat/tab-should-indent-highlighted-text

Conversation

@liltrendi

@liltrendi liltrendi commented May 23, 2025

Copy link
Copy Markdown
Contributor

Overview

Closes #110.

Normally, editors do support indentation based on where the cursor is positioned at:

  • If the cursor is at the start of the line, pressing TAB should add an indent from the beginning of the line
  • If the cursor is anywhere else within the line, pressing TAB should add an indent from the current cursor position
  • If there is a specific block of text highlighted, pressing TAB should add an indent relative to that text selection
  • SHIFT+TAB should do the inverse of all the operations mentioned above
  • Finally, selecting multiple lines and pressing either TAB or SHIFT+TAB, should work as explained above for the lines selected

This PR aims to implement this feature in a simple way.

Demo

Screen.Recording.2025-05-24.at.17.50.50.mov

@liltrendi

This comment was marked as resolved.

@lhecker lhecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unfortunately not sure if we can merge this in the current state. I apologize for that. 🙈

Aside from the issues I mentioned, I believe this needs some polishing, because it's currently significantly larger than it likely could be. I have a strong gut feeling that the feature can be implemented in around 100 lines of code with a general approach that's similar to the existing code.

Comment thread src/buffer/mod.rs Outdated
Comment thread src/buffer/mod.rs Outdated
Comment thread src/buffer/mod.rs Outdated
@liltrendi liltrendi requested a review from lhecker May 24, 2025 13:34
@liltrendi liltrendi changed the title Feature: Support Indentation On Highlighted & Unhighlighted Text With Tab Press [feat]: Support Indentation On Highlighted & Unhighlighted Text With Tab Press May 25, 2025
@liltrendi liltrendi changed the title [feat]: Support Indentation On Highlighted & Unhighlighted Text With Tab Press [feat]: support for single and multi line indentation May 25, 2025

@AmirTallap AmirTallap left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, thanks!

@liltrendi

Copy link
Copy Markdown
Contributor Author

I'm unfortunately not sure if we can merge this in the current state. I apologize for that. 🙈

Aside from the issues I mentioned, I believe this needs some polishing, because it's currently significantly larger than it likely could be. I have a strong gut feeling that the feature can be implemented in around 100 lines of code with a general approach that's similar to the existing code.

Please have a look; refactored the implementation with a leaner approach & added multi-line support. Thanks!

@lhecker

lhecker commented May 27, 2025

Copy link
Copy Markdown
Member

I'll review it again once I get a chance. 🙂

@liltrendi liltrendi requested a review from AmirTallap June 5, 2025 01:37
@liltrendi

Copy link
Copy Markdown
Contributor Author

@DHowett requesting extra eyes on this 👀 would be nice early on so as to alleviate frequent conflicts.

@lhecker

lhecker commented Jun 19, 2025

Copy link
Copy Markdown
Member

I'll go through this PR after #397 merges, as it introduces the ability to group multiple changes into a single undo. This will be very useful for this PR as well.

@lhecker lhecker changed the title [feat]: support for single and multi line indentation Support for multiline indentation Jun 23, 2025
@lhecker lhecker enabled auto-merge (squash) June 23, 2025 16:05
@lhecker lhecker requested review from DHowett and removed request for AmirTallap June 23, 2025 16:05

@DHowett DHowett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much both of you for doing this!

@liltrendi

Copy link
Copy Markdown
Contributor Author

LFG 🚀 thanks @lhecker @DHowett

@lhecker lhecker merged commit b4cd1f6 into microsoft:main Jun 24, 2025
3 checks passed
Lou32Verbose pushed a commit to Lou32Verbose/edit that referenced this pull request Jan 11, 2026
Closes microsoft#110

Co-authored-by: Leonard Hecker <leonard@hecker.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tab should indent highlighted text or move it to the left!

4 participants