NSTextView: copying a list item does not include list formatting on paste












0















I have a basic Mac app with a stock NSTextView ("Rich Document Content Text View" in Interface Builder), but I have also observed this behavior in TextEdit:




  1. Create a new bulleted list with 3 items

  2. Select and copy a single list item

  3. Paste the list item into the same document


→ The pasted item loses its list formatting, i.e. when I press Return at the end, no new list item is automatically added.



→ When I select two or more list items, it works correctly.



Here's a quick video:



NSTextView pasting a list item



Other observations



I tested the same procedure in Scrivener (which I believe also uses NSTextView), and here copying a single list item places the correct formatting list attributes on the clipboard.



I inspected the clipboard and when I copy a single list item, indeed, the RTF contents are different compared with Scrivener.



NSTextView (one item copied):



f0fs36 cf0   '95    Regular list item}


Scrivener (one item copied):



f0fs32 cf0 {listtext    uc0u8226  }Regular list item}


Note how Scrivener places the correct formatting on the clipboard.



NSTextView (two items copied):



f0fs36 cf0 {listtext    uc0u8226  }Regular list item
{listtext uc0u8226 }Another list item}


When copying two list items, it works as expected.



What am I missing? Or is this a bug/feature and the Scrivener folks are working around this in their app (e.g. detecting when a single list item is copied and fixing its attributes)?










share|improve this question



























    0















    I have a basic Mac app with a stock NSTextView ("Rich Document Content Text View" in Interface Builder), but I have also observed this behavior in TextEdit:




    1. Create a new bulleted list with 3 items

    2. Select and copy a single list item

    3. Paste the list item into the same document


    → The pasted item loses its list formatting, i.e. when I press Return at the end, no new list item is automatically added.



    → When I select two or more list items, it works correctly.



    Here's a quick video:



    NSTextView pasting a list item



    Other observations



    I tested the same procedure in Scrivener (which I believe also uses NSTextView), and here copying a single list item places the correct formatting list attributes on the clipboard.



    I inspected the clipboard and when I copy a single list item, indeed, the RTF contents are different compared with Scrivener.



    NSTextView (one item copied):



    f0fs36 cf0   '95    Regular list item}


    Scrivener (one item copied):



    f0fs32 cf0 {listtext    uc0u8226  }Regular list item}


    Note how Scrivener places the correct formatting on the clipboard.



    NSTextView (two items copied):



    f0fs36 cf0 {listtext    uc0u8226  }Regular list item
    {listtext uc0u8226 }Another list item}


    When copying two list items, it works as expected.



    What am I missing? Or is this a bug/feature and the Scrivener folks are working around this in their app (e.g. detecting when a single list item is copied and fixing its attributes)?










    share|improve this question

























      0












      0








      0








      I have a basic Mac app with a stock NSTextView ("Rich Document Content Text View" in Interface Builder), but I have also observed this behavior in TextEdit:




      1. Create a new bulleted list with 3 items

      2. Select and copy a single list item

      3. Paste the list item into the same document


      → The pasted item loses its list formatting, i.e. when I press Return at the end, no new list item is automatically added.



      → When I select two or more list items, it works correctly.



      Here's a quick video:



      NSTextView pasting a list item



      Other observations



      I tested the same procedure in Scrivener (which I believe also uses NSTextView), and here copying a single list item places the correct formatting list attributes on the clipboard.



      I inspected the clipboard and when I copy a single list item, indeed, the RTF contents are different compared with Scrivener.



      NSTextView (one item copied):



      f0fs36 cf0   '95    Regular list item}


      Scrivener (one item copied):



      f0fs32 cf0 {listtext    uc0u8226  }Regular list item}


      Note how Scrivener places the correct formatting on the clipboard.



      NSTextView (two items copied):



      f0fs36 cf0 {listtext    uc0u8226  }Regular list item
      {listtext uc0u8226 }Another list item}


      When copying two list items, it works as expected.



      What am I missing? Or is this a bug/feature and the Scrivener folks are working around this in their app (e.g. detecting when a single list item is copied and fixing its attributes)?










      share|improve this question














      I have a basic Mac app with a stock NSTextView ("Rich Document Content Text View" in Interface Builder), but I have also observed this behavior in TextEdit:




      1. Create a new bulleted list with 3 items

      2. Select and copy a single list item

      3. Paste the list item into the same document


      → The pasted item loses its list formatting, i.e. when I press Return at the end, no new list item is automatically added.



      → When I select two or more list items, it works correctly.



      Here's a quick video:



      NSTextView pasting a list item



      Other observations



      I tested the same procedure in Scrivener (which I believe also uses NSTextView), and here copying a single list item places the correct formatting list attributes on the clipboard.



      I inspected the clipboard and when I copy a single list item, indeed, the RTF contents are different compared with Scrivener.



      NSTextView (one item copied):



      f0fs36 cf0   '95    Regular list item}


      Scrivener (one item copied):



      f0fs32 cf0 {listtext    uc0u8226  }Regular list item}


      Note how Scrivener places the correct formatting on the clipboard.



      NSTextView (two items copied):



      f0fs36 cf0 {listtext    uc0u8226  }Regular list item
      {listtext uc0u8226 }Another list item}


      When copying two list items, it works as expected.



      What am I missing? Or is this a bug/feature and the Scrivener folks are working around this in their app (e.g. detecting when a single list item is copied and fixing its attributes)?







      cocoa copy-paste nsattributedstring nstextview nstextstorage






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 8:50









      MarkMark

      2,85212964




      2,85212964
























          1 Answer
          1






          active

          oldest

          votes


















          0














          It's a "feature".



          Try placing your cursor at the start (rather than the end of the line) and dragging down to select the line, copy, paste - you'll get a return at the end of the paste but if you back up to the end of the pasted line and hit return you'll find you get the list formatting.



          The formatting details for a "paragraph" are attached to the newlines, also when text is copied formatting info for the start of the selection is included.



          The source of TextEdit is available from Apple, the linked version is a few years old and Apple's documentation archive, you might find a newer version in the new "improved" documentation Apple provides, or lose your sanity looking ;-(. If you read it you can find out how these features/quirks of the text system are dealt with.



          HTH






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389266%2fnstextview-copying-a-list-item-does-not-include-list-formatting-on-paste%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It's a "feature".



            Try placing your cursor at the start (rather than the end of the line) and dragging down to select the line, copy, paste - you'll get a return at the end of the paste but if you back up to the end of the pasted line and hit return you'll find you get the list formatting.



            The formatting details for a "paragraph" are attached to the newlines, also when text is copied formatting info for the start of the selection is included.



            The source of TextEdit is available from Apple, the linked version is a few years old and Apple's documentation archive, you might find a newer version in the new "improved" documentation Apple provides, or lose your sanity looking ;-(. If you read it you can find out how these features/quirks of the text system are dealt with.



            HTH






            share|improve this answer




























              0














              It's a "feature".



              Try placing your cursor at the start (rather than the end of the line) and dragging down to select the line, copy, paste - you'll get a return at the end of the paste but if you back up to the end of the pasted line and hit return you'll find you get the list formatting.



              The formatting details for a "paragraph" are attached to the newlines, also when text is copied formatting info for the start of the selection is included.



              The source of TextEdit is available from Apple, the linked version is a few years old and Apple's documentation archive, you might find a newer version in the new "improved" documentation Apple provides, or lose your sanity looking ;-(. If you read it you can find out how these features/quirks of the text system are dealt with.



              HTH






              share|improve this answer


























                0












                0








                0







                It's a "feature".



                Try placing your cursor at the start (rather than the end of the line) and dragging down to select the line, copy, paste - you'll get a return at the end of the paste but if you back up to the end of the pasted line and hit return you'll find you get the list formatting.



                The formatting details for a "paragraph" are attached to the newlines, also when text is copied formatting info for the start of the selection is included.



                The source of TextEdit is available from Apple, the linked version is a few years old and Apple's documentation archive, you might find a newer version in the new "improved" documentation Apple provides, or lose your sanity looking ;-(. If you read it you can find out how these features/quirks of the text system are dealt with.



                HTH






                share|improve this answer













                It's a "feature".



                Try placing your cursor at the start (rather than the end of the line) and dragging down to select the line, copy, paste - you'll get a return at the end of the paste but if you back up to the end of the pasted line and hit return you'll find you get the list formatting.



                The formatting details for a "paragraph" are attached to the newlines, also when text is copied formatting info for the start of the selection is included.



                The source of TextEdit is available from Apple, the linked version is a few years old and Apple's documentation archive, you might find a newer version in the new "improved" documentation Apple provides, or lose your sanity looking ;-(. If you read it you can find out how these features/quirks of the text system are dealt with.



                HTH







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 10:30









                CRDCRD

                44.8k44870




                44.8k44870






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389266%2fnstextview-copying-a-list-item-does-not-include-list-formatting-on-paste%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                    Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

                    A Topological Invariant for $pi_3(U(n))$