GithubHelp home page GithubHelp logo

vscode-align-by-regex's People

Contributors

janjoerke avatar joerkeja avatar softwareape avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vscode-align-by-regex's Issues

Weird alignment on Markdown table

I tried to align this table:

I|have|a|table
It|is|not|aligned

with Regex '\|' and got the following:

I |have|a|table
It|is|not|aligned

Unexpectedly aligns matching lines against non-matching lines

I have a file with comments, like:

function blah() { "hi there" }
# This function does amazing things the likes of which you have never seen.
function longerfunc() { "hi there" }

Actual:

Aligning against "{" creates this:

function blah()                                                            { "hi there"}
# This function does amazing things the likes of which you have never seen.
function longerfunc()                                                      { "hi there"}

Expected:

I expected it to ignore non-matching lines and create this:

function blah()       { "hi there"}
// This function does amazing things the likes of which you have never seen.
function longerfunc() { "hi there"}

Unexpected Alignment 2

Here's an example:

Input:

a(123) // 123
bb(45)  // 45
ccc(6)   // 6

Align by Regex: \(

Output:

a  (123) // 123
bb (45) // 45
ccc(6) // 6

Expected:

a  (123) // 123
bb (45)  // 45
ccc(6)   // 6

For some reason, the command changed the number of spaces after the match point.
The expectation is that everything after the match would remain unchanged, but only the match point will be aligned.

Feature request: enable args to use in shortcuts

This would allow, e.g., the following keyboard shortcuts

{
  "key": "shift+alt+=",
  "command": "align.by.regex",
  "args": "=",
  "when": "editorHasSelection"
}

{
  "key": "shift+alt+[",
  "command": "align.by.regex",
  "args": "[",
  "when": "editorHasSelection"
}

Tab alignment

Tabs are counted as single characters. VSCode has the tab size setting editor.tabSize which should make it possible to align with tabs.

Failing case:

a.
	b.

(b is indented with tab)

after aligning by dot (".") becomes

a .
	b.

The . is aligned on index 2. Dot on second line is also index 2, but looks like index 5 if your tab size is 4.

Extension breaks on bad Regex

Just tried out the version 1.0.2. I tried aligning a markdown table, e.g.

I|have|a|table
It|is|not|aligned

I accidentally entered '|' instead of escaping it as '\|' and after that my computer started heating up and I couldn't call up the command menu in VSCode.

Is it possible to "select" the character of alignement ?

Hi
is it possible to "select" the character of alignement ?

For example, i have the following code (it is from a constraint XDC file but whatever)

set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN  } [get_ports RXDATA_A[7] ]
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN  } [get_ports RX_A[0] ]

If i use the extenstion to align with ']' i've got:

set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN  } [get_ports RXDATA_A[7] ]
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN  } [get_ports RX_A[0      ] ]

But what i want is:

set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN  } [get_ports RXDATA_A[7] ]
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN  } [get_ports RX_A[0]     ]

i would like to configure alignbyregex to align to the Nth character not the first one.

Alignment unexpectedly includes line after selection

After selecting a set of lines, the end of the selection is often at the beginning of the next line, which causes the plugin to include that line in the alignment. This is unexpected behavior since no part of the line is actually selected.

  1. Put the cursor at the top of this:
a - 1
ab - 2
abcd - 4
abcdefg - 8
abcdefghijklmno - 16
  1. Hold shift, and hit "down" 3 times to select the first 3 lines.

Expected Behavior:

Aligns the first three lines:

a    - 1
ab   - 2
abcd - 4
abcdefg - 8
abcdefghijklmno - 16

Actual Behavior:

Aligns the first four lines:

a       - 1
ab      - 2
abcd    - 4
abcdefg - 8
abcdefghijklmno - 16

[Feature Request]: Ignore comment line when processing alignment

Is it possible to ignore comment line when alignment is performed ?

For example, i work on VHDL file:
`-- This line is a long comment ( if bar <= 2 it is ko )

foo <= bar(2 downto 0);
long_long__name <= '0';
`
I want to align my code with '<=' but only on "real" code line.

Thanks.

publish on open-vsx.org

could you please publish this extension on open-vsx.org? I switched to vscodium, so this really useful addon is no longer available for me, and this kinda sucks in my day-to-day work. i'd be really grateful :)

[Feature Request] Extend Template System

I propose that the template system be expanded to

  • allow users to create collections of predefined patterns without having to remember the exact names and letter-cases
  • prevent erroneous interpolation
    • EG: intended literal SomeWord is translated to (SomeRegEx)

Example

Commands

"align.by.regex.showTemplates"
// shows a searchable command palette list of user's "align.by.regex.templates"

Settings

"align.by.regex.templates": {
  "SomeWord": "(SomeRegEx)",
}

"align.by.regex.interpolationPrefix" = "{{"
"align.by.regex.interpolationSuffix" = "}}"

"align.by.regex.interpolationMode"
// "plainText":
//    - user input "SomeWord" will be translated to "(SomeRegEx)"
// "interpolate":
//    - implements "align.by.regex.interpolationPrefix"
//      & "align.by.regex.interpolationSuffix" settings
//    - user input  "SomeWord"        will be translated to  "SomeWord"
//    - user input  "1{{SomeWord}}2"  will be translated to  "1(SomeRegEx)2"
// "none":
//    - templates are only available via the "align.by.regex.showTemplates" command

"align.by.regex.interpolationCaseSensitive"
//  true
//    - user input  "SomeWord"  will be translated to  "(SomeRegEx)"
//    - user input  "someword"  will be translated to  "someword"
//  false
//    - user input  "SomeWord"  will be translated to  "(SomeRegEx)"
//    - user input  "someword"  will be translated to  "(SomeRegEx)"

Escape parenthesis in templates ?

Hi

Maybe i'm making a mistake into configuration, but is it possible to have template with escape characters ?

For exemple, i want to create a template to align with parenthesis. But in regex in must escape parenthesis. So i've created the following template:
parent = "(|)"

But vscode, says me that is an unvalid escape character.

How can i do this type of template ?

Thanks.

No spaces between words at the end of long lines.

When I have a text with long lines, e.g.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

And I use align by regex, it aligns correctly but mashes together the words at the ends of long lines (I aligned by comma, but it doesn't render correctly on Github).

Lorem ipsum dolor sit amet , consectetur adipiscing elit , sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodoconsequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id estlaborum.

Feature Request: maximum alignment

I'm using this plugin to align my tests, which tend to have a lot of semi-short tests, sprinkled alongside a very small smattering of super-long ones (this is just a small sample for reference):

#[test] fn declare_missing_right() { expect( "a: ; a" ).to_error( MissingOperand, 1..=1 ) }
#[test] fn declare_missing_left() { expect( ": 1" ).to_error( MissingOperand, 0..=0 ) }
#[test] fn declare_missing_both() { expect( ":" ).to_error( MissingOperand, 0..=0 ) }
#[test] fn declare_precedence() { expect( "a: false; b: false || true && 14 == 2 + 3 * 4; b" ).to_yield( true ) }
#[test] fn declare_non_field() { expect( "1: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=0 ) }
#[test] fn declare_non_field_expr() { expect( "1+2: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=2 ) }

Current Behavior:
Currently, aligning by {|\)\. (rightly) causes all the lines to be aligned to the long one. This makes the whole file feel out of whack:

#[test] fn declare_missing_right()  { expect( "a: ; a"                                           ).to_error( MissingOperand, 1..=1 )}
#[test] fn declare_missing_left()   { expect( ": 1"                                              ).to_error( MissingOperand, 0..=0 )}
#[test] fn declare_missing_both()   { expect( ":"                                                ).to_error( MissingOperand, 0..=0 )}
#[test] fn declare_precedence()     { expect( "a: false; b: false || true && 14 == 2 + 3 * 4; b" ).to_yield( true )}
#[test] fn declare_non_field()      { expect( "1: 1"                                             ).to_error( AssignmentTargetMustBeIdentifier, 0..=0 )}
#[test] fn declare_non_field_expr() { expect( "1+2: 1"                                           ).to_error( AssignmentTargetMustBeIdentifier, 0..=2 )}

Desired Behavior:

I'd like to be able to either (a) let me specify maximums, or even better, (b) have it use some kind of outlier detection (like, pick things close to the P90--i.e. if there are a hundred lines, pick the length of the 90th line instead of the 100th), or (b) specify a maximum indent to keep the file from getting too hard to read. I'd like it to look like this, in short:

#[test] fn declare_missing_right()  { expect( "a: ; a" ).to_error( MissingOperand, 1..=1)}
#[test] fn declare_missing_left()   { expect( ": 1"    ).to_error( MissingOperand, 0..=0)}
#[test] fn declare_missing_both()   { expect( ":"      ).to_error( MissingOperand, 0..=0)}
#[test] fn declare_non_field()      { expect( "1: 1"   ).to_error( AssignmentTargetMustBeIdentifier, 0..=0)}
#[test] fn declare_non_field_expr() { expect( "1+2: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=2)}
#[test] fn declare_precedence()     { expect( "a: false; b: false || true && 14 == 2 + 3 * 4; b" ).to_yield( true )}

Unexpected alignment

It seems that the aligner modifies the text prior the match point.
That is not expected.

Example:
Original text:

a    a(aaa)
b   b(bbbb)
c  c(c)
d d(ddddddd)

Align By Regex: \).*$

Result:

a a(aaa    )
b b(bbbb   )
c c(c      )
d d(ddddddd)

Expected:

a    a(aaa )
b   b(bbbb )
c  c(c     )
d d(ddddddd)

the position of the text before the match point has been modified.
My expectation was that only the match and text after it will be moved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.