Uh oh!
There was an error while loading. Please reload this page.
Add editor formatting service to auto-deindent closing brackets - #3313
Conversation
cartermp
left a comment
There was a problem hiding this comment.
This is great. Just have two suggestions. Not sure if the scenario implied by them is realistic though.
| asyncMaybe { | ||
| let! options = optionsOpt | ||
| let line = sourceText.Lines.[sourceText.Lines.IndexOf position] |
There was a problem hiding this comment.
Not sure if this is realistic or would ever get hit, but max 0 (sourceText.Lines.IndexOf position) would be useful.
Perhaps this is just me being paranoid after #3180.
There was a problem hiding this comment.
IndexOf throws if the position isn't within the text, but as Roslyn has already supplied us with the position I think it's impossible that we can't find the line in the source text (also supplied by Roslyn).
| |> Seq.takeWhile ((=) ' ') | ||
| |> Seq.length | ||
| let startIndent = indentChars sourceText.Lines.[sourceText.Lines.IndexOf leftSpan.Start] |
There was a problem hiding this comment.
Same as above, or perhaps check this before hand if a startIndent of 0 would cause trouble?
There was a problem hiding this comment.
Tested with startIndent 0 and everything's fine :)
cartermp
commented
Jul 8, 2017
Also, perhaps making this be driven by an editor option (and on by default) would also be good if that's possible. I imagine some people would like to turn it off if they prefer a more plain editor. |
saul
commented
Jul 8, 2017
Phillip I've set it so that smart indentation is only done if the indentation style is set to 'Smart' in the editor settings. However I think by default it's set to 'Block' and I think we should move everyone over to this style by default - any thoughts as to how we could do this? |
vasily-kirichenko
commented
Jul 8, 2017
I'm for as smart style as possible by default. After writing some Kotlin in Inellij F# VS editor feels annoyingly dumb. |
cartermp
commented
Jul 8, 2017
@dotnet-bot test this please |
saul
commented
Jul 8, 2017
Phillip it's shown as an option but it's not the default |
cartermp
commented
Jul 8, 2017
Ah, I was mistaken in thinking this was what should also set it. Clearly not the case based on the docs for that. I've no idea where this would be set. Isn't there a common place where we're setting some of the newer settings which were added? |
forki
commented
Jul 9, 2017
This is great. Is this something that other editors can use as well? /cc @Krzysztof-Cieslak |
forki
commented
Jul 9, 2017
Ok everything is in vsintegration. So that's a no. ;-( |
vasily-kirichenko
commented
Jul 9, 2017
I'm still waiting when anything from Code can be used in VS. |
Most of the fable, react, react native tooling is develop in code. That stuff will flow to VS in vnext. Also a lot of the paket / netcore integration stuff. It's all done so that all editors benefit |
Krzysztof-Cieslak
commented
Jul 9, 2017
I'm still waiting for features be implemented in FCS instead of being coupled with VS. At least in our case features are shared between xplat editors using FSAC. |
dsyme
commented
Jul 10, 2017
@Krzysztof-Cieslak I've a WIP integration of a large amount of work into the FCS repo , where we will do final testing on FCS (which actually caught some issues), add some documentation and a release. After this integration the whole test/release process should be easier. We will also accept contributions directly to FCS and cherry-pick them into VS if people have a strong preference to contribute them directly to FCS. |
Pilchie
commented
Jul 10, 2017
@jasonmalinowski do you know how to set the default value for indenting for a language service to "Smart"? |
@dsyme, I think I do understand the workflow ;) My point was about the fact that whole logic of this feature (and many others) is implemented in Anyway, great feature. 💯 |
vasily-kirichenko
commented
Jul 12, 2017
I meant that VF(P)T -> Ionide should not be one way road. If you like this feature be available in Ionide, make a PR here, moving the logic to FCS. People here don't care about Ionide, just as you don't care about VS. |
Krzysztof-Cieslak
commented
Jul 12, 2017
You don't care about Ionide. Pretty sure lot of contributors and maintainers of this repo care about xplat tooling |
vasily-kirichenko
commented
Jul 12, 2017
OK, it's me who don't care :) Anyway, what about the PR?.. |
dsyme
commented
Jul 12, 2017
I care about Ionide, very very much. I use it all the time and am slowly trying to learn how to contribute to it. You don't have to care about Visual Studio IDE Tools to contribute to F# bits in this repo (except to make sure they continue to compile and pass CI tests as part of your PR).
I agree with this |
KevinRansom
commented
Jul 12, 2017
@vasily-kirichenko@Krzysztof-Cieslak@dsyme. I would love to have a plan where Ionide and VS Tools shared code. However, I am not smart enough or knowledgeable enough to figure out how that would work. Perhaps one day we will get there ... for sure Ionide is something we care about. |
cartermp
commented
Jul 21, 2017
FYI - asked around about how to set this as the default. Lots of folks taking vacations this time of year, but I'll follow up on that again. I'm fine with taking this for now and then creating a separate issue for Smart Indent being the default. |
saul
commented
Jul 21, 2017
Thanks Phillip. I'm also on vacation now so I can't get around to fixing the tests until week after next. |
cartermp
commented
Jul 21, 2017
Sounds good. I'll flag this for follow-up ~1.5 weeks for now. Have a good time! |
saul
commented
Aug 23, 2017
It's worth noting we need a way to move everyone's 'Tab Style' to 'Smart' (as C# does) - otherwise people won't get any kind of auto indentation. Note that then we'd match C#'s behaviour. |
saul
commented
Aug 23, 2017
cc @KevinRansom@cartermp see comment above |
KevinRansom
commented
Aug 23, 2017
@saul without enabling by default, discovery will be hard, so I agree it should probably be the default. However, people often dislike default changes, even when the change is useful stuff. Does that make sense? |
saul
commented
Aug 23, 2017
It's not a default change per se as the current behaviour will be moved to only act that way if 'Smart' is enabled. So to the end user indentation will work exactly the same, except it will de-indent too (that's what this PR is adding). |
KevinRansom
commented
Aug 23, 2017
@saul I'm sorry I misunderstood the question. Making the auto de-indent "smart indent only" only seems right. I think we should consider making smart the default, when we are sure the experience is solid. Does that help? |
cartermp
commented
Aug 23, 2017
The question is how we do that. It's the default for me on a fresh installation of VS, and I've never gone in to set it myself, which is why that setting is confusing to me. The experience with this PR (and @xuanduc987's) is great, IMO. The editor feels smart. |
KevinRansom
commented
Aug 24, 2017
It's a VS setting thingy ... there's some way of setting defaults in the internal VS codebase. I seem to remember Lincoln working it out ages ago, in order to ensure that tabs as spaces is set. I expect Johnathan or Brett know the magic goo. |
KevinRansom
commented
Aug 24, 2017
@dotnet-bot Windows_NT Release_ci_part1 Build please |
saul
commented
Aug 24, 2017
@KevinRansom I know about the failing test cases. Also I think there's a way that we can make Jenkins outside more readable - is there a reason why we aren't parsing the NUnit test report XML? I may open a new PR that makes reading CI failures palpable. |
forki
commented
Aug 24, 2017
via email
I'm very in favor of having better build output. But usually we only fix
the current issue to be displayed better. All bigger efforts to change
things more fundamentally never made it in.
Displaying nunit errors im CI should be a good small move. But don't forget
that a big part of the test suite is not nunit.
Am 24.08.2017 10:10 vorm. schrieb "Saul Rennison" <notifications@github.com …:
@KevinRansom <https://github.com/kevinransom> I know about the failing
test cases.
Also I think there's a way that we can make Jenkins outside more readable
- is there a reason why we aren't parsing the NUnit test report XML? I may
open a new PR that makes reading CI failures palpable.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3313 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNA7M3LFORXm8FjLjstkGkz8eY4udks5sbS_jgaJpZM4ORXN8>
.
|
realvictorprm
commented
Aug 24, 2017
This looks super useful, @saul is this in such a state that I can safely install it 😝 ? |
saul
commented
Aug 24, 2017
via email
Indeed it is! …________________________________
From: Victor Peter Rouven Müller <notifications@github.com>
Sent: Thursday, August 24, 2017 10:00:27 AM
To: Microsoft/visualfsharp
Cc: Saul Rennison; Mention
Subject: Re: [Microsoft/visualfsharp] Add editor formatting service to auto-deindent closing brackets (#3313)
This looks super useful, @saul<https://github.com/saul> is this in such a state that I can safely install it 😝 ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#3313 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAD8jp47-465F0jdSBx4JzoONCUHc2rCks5sbTurgaJpZM4ORXN8>. |
cartermp
commented
Aug 24, 2017
@dotnet-bot Windows_NT Release_ci_part1 Build please Timeout on the CI server... |
cartermp
commented
Aug 25, 2017
@saul An error in the log here: |
abelbraaksma
commented
Aug 25, 2017
Still WIP, other tests still broken
saul
commented
Sep 2, 2017
@cartermp when this goes green it's ready to merge. |
saul
commented
Sep 2, 2017
@dotnet-bot please test Windows_NT Release_ci_part2 |
saul
commented
Sep 4, 2017
@KevinRansom@cartermp this is ready to merge |
KevinRansom
commented
Sep 6, 2017
@saul Kevin |
…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 Fixesdotnet#2092
At no point in this GIF do I Shift-Tab to de-indent. Closing braces automatically deindent to the same indentation level as that of the opening brace.
It performs the de-indent check on Enter, and when one of ), ] or } is pressed.