Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brace Highlighting Should Activate at more positions #2092

Closed
cloudRoutine opened this issue Dec 23, 2016 · 2 comments
Closed

Brace Highlighting Should Activate at more positions #2092

cloudRoutine opened this issue Dec 23, 2016 · 2 comments

Comments

@cloudRoutine
Copy link
Contributor

I marked out the columns where brace matching activates and where it does not
o means it activates on the following col, x means it doesn't i.e.


(*          ox          xo        *)
    let a1 = [ 0 .. 100  ]
(*          oxx          xox        *)
    let a2 = [| 0 .. 100  |]
(*          oxx    xox        *)
    let a3 = <@ 0   @>
(*          oxxx     xoxx        *)
    let a4 = <@@  0   @@>
(*          ox     xo        *)
    let a6 = (  ()  )
(* oxx                  xox     *)
    [<ReflectedDefinition>]
    let a7 = 70
(*              ox        xo     *)
    let a8 = seq { yield() }
(*     oxx   xxo         *)
    let (| A9 |) = ()

I think brace matching should activate on either side of the brace and at all positions inside of the brace for multi column braces

It doesn't activate at all for -

  • (* *)
  • begin end
  • struct end
  • class end
  • interface end
  • < > for generics

[ vs2017 rc2 with latest tools built from master ]

@vasily-kirichenko
Copy link
Contributor

+500 for this.

@cartermp cartermp added Area-LangService-API Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Dec 26, 2016
@cartermp cartermp added this to the VS 2017 Updates milestone Jan 6, 2017
@dsyme dsyme added Feature Request and removed Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Feb 2, 2017
@saul
Copy link
Contributor

saul commented Sep 2, 2017

With my latest PR (#3313), we're returning the correct braces to Roslyn. However, Roslyn explicitly ignores them. See http://source.roslyn.io/#Microsoft.CodeAnalysis.EditorFeatures/Implementation/BraceMatching/BraceHighlightingViewTaggerProvider.cs,3ee09e525b0037c8

/// Given code like   ()^()  (where ^ is the caret position), returns the two pairs of
/// matching braces on the left and the right of the position.  Note: a brace matching
/// pair is only returned if the position is on the left-side of hte start brace, or the
/// right side of end brace.  So, for example, if you have (^()), then only the inner 
/// braces are returned as the position is not on the right-side of the outer braces.
/// 
/// This function also works for multi-character braces i.e.  ([  ])   In this case,
/// the rule is that the position has to be on the left side of the start brace, or 
/// inside the start brace (but not at the end).  So,    ^([   ])  will return this
/// as a brace match, as will  (^[    ]).  But   ([^   ])  will not.
/// 
/// The same goes for the braces on the the left of the caret.  i.e.:   ([   ])^
/// will return the braces on the left, as will   ([   ]^).  But   ([   ^]) will not.

You need to raise the issue with Roslyn, as they explicitly do not allow what you're asking (I agree it's counterintuitive).

saul added a commit to saul/fsharp that referenced this issue Sep 2, 2017
@cartermp cartermp modified the milestones: VS 2017 Updates, 15.4 Jun 9, 2018
nosami pushed a commit to xamarin/visualfsharp that referenced this issue Jan 26, 2022
…et#3313)

* Add editor formatting service for auto-deindent

* Minor refactor of the indentation service - do not indent after 'function'

* Only use smart indentation if indent style is set to 'Smart'

* Fix broken unit test build

* Implement review comments, fix build

* Fix some broken brace matching tests

Still WIP, other tests still broken

* Fix failing indentation tests

* Add formatting service tests

* Add more brace matching tests

Fixes dotnet#2092
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants