Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript Editor Not Remembering Cursor Position

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Hello jeronymite,

    When editing braces (i.e. {}), the editor automatically expands everything below the editing point if an opening brace that already has a matching closing brace is deleted. This does not happen if the matching closing brace is the one deleted. This leads to a continually frustrating experience of having to re-collapse the code below if that is the view one wanted.
    I tried to piece together what you are doing in this description however I was unable to see the described result. If you have a specific example that demonstrates this I could forward that to development. A specific example in this case would be something like a specific piece of code that can demonstrate the issue. I tried collapsing a method and deleting the braces with a method above it but that did not change the collapsed method.

    For the find, I will put in a request for that, for the time being visual studio would need to be used in order to use the more advanced find/replace features.


    Please let me know if I may be of further assistance.

    Comment


      #17
      Thanks for continuing on with this series of issues, Jesse. Very much appreciated.

      The following can be used to demonstrate the issue:
      Code:
      namespace EditorTest
      {[INDENT]public class Test
      {[/INDENT][INDENT=2]public void Method1()
      {[/INDENT][INDENT=3]bool b1;
      if (b1)
      {[/INDENT][INDENT=4]// Do something[/INDENT][INDENT=3]}[/INDENT][INDENT=2]}
      
      public void Method2()
      {[/INDENT][INDENT=3]bool b2;
      if (b2)
      {[/INDENT][INDENT=4]// Do something[/INDENT][INDENT=3]}[/INDENT][INDENT=2]}[/INDENT][INDENT]}[/INDENT]
       }
      With everything collapsed below the edit point, delete any opening brace (except the opening brace of the namespace, which does not seem to cause the issue) and everything below is expanded. I've notice that this occurs with other forms of parenthetical usage too, not just braces; but I haven't tried to isolate those cases since they all share a similar type of footprint.

      Hope that works for you.

      Thanks.
      Last edited by jeronymite; 08-31-2020, 04:10 PM.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #18
        Hello jeronymite,

        This will not compile as is, did you have a sample that you have tested on your end and can see the described issue? If so please attach that file directly as a .cs file so I can see the full context. I would also need that context to know where the file goes, for example is it in the indicators folder, addons folder etc..

        Please also include specifics on what needs edited in the file to see the problem (line number or add a comment in the file).

        Please let me know if I may be of further assistance.

        Comment


          #19
          Hi Jesse,

          Perhaps I have not been clear, and forgive me if that is the case.

          The problem is in how the editor behaves, not in what the code does. The code could be anything. When one is editing, the code invariably will be uncompilable through much of that time -- that is entirely to be expected in the process of editing.

          To see the editor's issue with braces/parentheses, simply create a new AddOn and then replace all the code with the example code above and do as previously mentioned. The fact that it is not valid code for an AddOn is irrelevant in this testing context. Even with valid AddOn code, the same behaviour is exhibited. I hope that makes it clearer.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #20
            Hello jeronymite,

            In this situation I would suggest to form a more complete sample and I can test that for you. The details you have provided so far have not been able to let me test this or see the issue.

            It looks like you edited the post yesterday after I had tested the code,which means the code you edited no longer represents what I tested. When I had tested the code it was not valid so I was unable to see the issue. The edited code is still not helpful in telling what I need to edit to see the issue.

            To continue further with this please provide a .cs file that includes the code you had used and include a comment in the file where the change needs to be made to see the problem. I don't know what you are referring to when you say " With everything collapsed below the edit point", there are not specific details on what you were editing when you saw the problem.

            The editors formatting is based on the structure of your file so if you are making invalid structure or causing a problem with the structure in general that could cause the editor to incorrectly interpret the file. Once you have corrected the structure it should be able to utilize the normal C# formatting and other features.



            Please let me know if I may be of further assistance.

            Comment


              #21
              Hi Jesse,

              Here's a simple way to reproduce the issue:
              1. Open a new NinjaScript Editor
              2. Create a New Strategy
              3. Generate the Strategy immediately (no specific customisation required)
              4. Collapse the view
              5. Delete the open brace on line 29 (the opening brace for public class MyCustomStrategy)
              6. The view immediately expands all code below the point at which you deleted the brace
              Thanks.

              Edit: Additional testing on this example shows that deleting an open parenthesis, for example the open parenthesis for the OnStateChange() method declaration on line 30, causes the same behaviour. This behaviour seems to occur for every open brace/parenthesis. For example, with OnStateChange() expanded, but OnBarUpdate() collapsed, deleting any of the open braces/parentheses above OnBarUpdate() causes OnBarUpdate() to expand.

              Deleting closing braces/parentheses does not elicit the behaviour every time, but it does sometimes. For example, with OnBarUpdate() collapsed, deleting the close brace on line 54 causes expansion of OnBarUpdate() but deleting the close brace on line 57 or line 58 does not. Similarly, with the view collapsed, deleting the close parenthesis of the OnStateChange() method declaration on line 30 does not cause expansion.

              Similar behaviour is more widespread than just parenthetical examples. With the code collapsed, deleting the word void on line 30 causes expansion, but just of the OnStateChange() method. However, deleting just the "v" of the word, leaving it as "oid", causes no change.

              I note that the behaviour is the same regardless of whether either or both of the editor properties Inline syntax checking and Auto bracket/quotes completion are enabled or disabled. I also note that although this example uses Strategy, the same behaviour is exhibited in AddOns. I have not tested editing other NinjaScript objects, but I would expect similar results.

              All these cases are problematic in one form or another. At best, the behaviour is inconsistent and unwarranted.
              Last edited by jeronymite; 09-01-2020, 05:17 PM. Reason: Added additional test results and commentary.
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment


                #22
                Hello jeronymite,

                Thanks for the additional details. I will review this and see what I can report here. Given the location and items you are editing I would expect that the collapsing does not work in those cases. You are deleting the brace or other structure that is required to make the script valid. If there are other cases where you are not directly changing the structure of the file we could look further into that.

                Just as a side note you can see the same behavior in visual studio so am I am not sure there is anything to be done there other than try to avoid making invalid structure.

                Please let me know if I may be of further assistance.

                Comment


                  #23
                  Thanks, Jesse.

                  I understand the apparent rationale behind the behaviour, but it is, at best, inconsistent. Any of the changes to any parenthetical as mentioned above creates an invalid structure, including deleting the closing parenthetical. So, in theory at least, every deletion, open or close, should cause the same behaviour. Worse than that: merely typing in new code that requires adding an open brace will cause the behaviour. Requiring Auto-complete braces is not the answer.

                  That notwithstanding, expanding everything from where an open brace is deleted to the end of the document is extreme overkill. In a document of, say, some thousands of lines (common in the work I'm doing), if I delete (or add) an open brace at the top somewhere, suddenly the entire document is expanded. Most undesirable! This should, at the very least, be an option one can disable. As one possible approach, I would suggest that if Inline syntax checking is disabled, it should also disable this behaviour.

                  Thanks for following through on this. Very much appreciated.
                  Multi-Dimensional Managed Trading
                  jeronymite
                  NinjaTrader Ecosystem Vendor - Mizpah Software

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Today, 05:17 AM
                  0 responses
                  44 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  124 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  65 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  42 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  46 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X