Skip to content

Saving a script file under a different name results in loss of colorization #1944

Closed

Description

@dsyme

Saving a script file under a different name results in loss of colorization

Repro steps

Provide the steps required to reproduce the problem

  1. Take script1.fsx containing some F# code. Observe its colors

  2. Save it as script2.fsx. Observe its colors

Expected behavior

Colorized in both cases

Actual behavior

Colorized only prior to the save-as operation

Known workarounds

close/open the file

Activity

  1. changed the title [-]Saving a script file under a different name results in loss of colorization[/-] [+][ VS2017 RC] Saving a script file under a different name results in loss of colorization[/+] on Dec 5, 2016
  2. added
    Impact-High
    on Dec 5, 2016
  3. dsyme commented on Dec 5, 2016

    @dsyme
    ContributorAuthor

    We should test similar scenarios in projects as well (e.g. adding/deleting/renaming files in projects)

  4. cartermp commented on Dec 5, 2016

    @cartermp
    Contributor

    I can't repro this on master from up until here: 4b8aafd

  5. rojepp commented on Dec 8, 2016

    @rojepp
    Contributor

    Can't repro either, using VisualFSharpOpenSource from a few days ago.

  6. cartermp commented on Dec 19, 2016

    @cartermp
    Contributor

    Got it to repro:

    loss-colorization

    It looks like reserved keywords aren't getting colorized, but type information is.

    Repro steps (on latest master):

    1. Create Script1.fsx in a new Console Application
    2. Type the following code:
    type BST<'T> =
        | Empty
        | Node of 'T * BST<'T> * BST<'T>
    
    let getStringAsync(str: string) = async { return str }
    
    let fooAsync() = async {
        let! str1 = getStringAsync "hello"
        let! str2 = getStringAsync "world"
        return str1 + str2
    }

    Now rename it to Script2.fsx, and observe the above.

  7. cartermp commented on Dec 19, 2016

    @cartermp
    Contributor

    Looks like IEditorClassificationService.AddSyntacticClassificationsAsync isn't invoked on a rename, as per @brettfo's suspicions.

  8. saul commented on Dec 31, 2016

    @saul
    Contributor

    I didn't even need to rename the file. I added the file to an existing project, pasted the code, saved it and then I suffered the same discolouration as above.

  9. cartermp commented on Jan 6, 2017

    @cartermp
    Contributor

    @Pilchie @brettfo Is this something we can address from the Roslyn side? Syntactic Classification isn't called for script files under certain circumstances.

  10. added this to the milestone on Jan 6, 2017
  11. Pilchie commented on Jan 6, 2017

    @Pilchie
    Member

    This would happen if the ITextSnapshot doesn't correspond to a Document that is part of the Workspace. I don't think this a Roslyn issue.

  12. majocha commented on Mar 20, 2017

    @majocha
    Contributor

    Simple repro is to rename a script file in Solution Explorer.

    Cause of this bug is that we currently don't handle script file renaming. Roslyn exports a MiscellaneousFilesWorkspace which tracks renaming scripts by implementing IVsRunningDocTableEvents2 but we don't use it.

  13. 6 remaining items

  14. added
    Impact-Medium
    and removed
    Impact-High
    on May 16, 2017
  15. changed the title [-][ VS2017 RC] Saving a script file under a different name results in loss of colorization[/-] [+]Saving a script file under a different name results in loss of colorization[/+] on Jul 28, 2017
  16. cdutcher commented on Feb 2, 2018

    @cdutcher

    Is there any eta or plan for this fix?

  17. cartermp commented on Feb 2, 2018

    @cartermp
    Contributor

    Not at the moment, no.

  18. saul commented on Feb 2, 2018

    @saul
    Contributor

    Shame - I fixed this is #2909.

  19. cartermp commented on Feb 2, 2018

    @cartermp
    Contributor

    I’m actually keen on getting that PR worked on, or at least chunks pulled out and merged. But we sinply lack the bandwidth right now due to .NET Core platform and tooling bringup.

  20. saul commented on Feb 2, 2018

    @saul
    Contributor

    I’ll pull out the fix for this issue now and take a stab at using the MiscellaneousFilesWorkspace - that’s the proper fix (but we couldn’t use it back then)

  21. cartermp commented on Feb 2, 2018

    @cartermp
    Contributor

    @saul Awesome! Just in terms of timeframe, VS 15.6 release is unlikely to take a fix like this since we're nearly locked down, but 15.7 is still quite open.

  22. modified the milestones: , 16.0 on Jun 20, 2018
  23. cartermp commented on Sep 5, 2018

    @cartermp
    Contributor

    Just as an update, renaming a .fs file to a .fsx triggers this issue, forcing a re-open of the document.

    Now that we depend on updated Roslyn and editor binaries, we could probably fix this a lot easier than before.

  24. saul commented on Oct 9, 2018

    @saul
    Contributor

    Fixed by @TIHan's PR: #5733

  25. cartermp commented on Nov 28, 2018

    @cartermp
    Contributor

    Closing as fixed. Note that we're also in the process of letting Roslyn effectively handle this all for us with a proper workspace here: dotnet/roslyn#31134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LangService-APIBugImpact-MediumRegression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions