MarkdownEditing icon indicating copy to clipboard operation
MarkdownEditing copied to clipboard

feature request - toggle changing list character on indent or outdent of list

Open jonathanmorgan opened this issue 11 years ago • 12 comments

Another quick one: Would it be possible to make the behavior where you change the leading list character whenever you indent or outdent a list item configurable, so I can turn it off? I generally just use hyphens, so the lists stay close to normal text lists in case someone just wants the straight up markdown file, and with this behavior, I have to go back and clean up the list characters whenever I have to tab.

As always, this is a great package, makes sublime the best markdown editor I've found.

Thanks,

Jon

jonathanmorgan avatar Feb 23 '15 06:02 jonathanmorgan

Sure. You can do that in your markdown user settings:

// Automatically switches list bullet when indenting blank list item with <Tab>.
"mde.list_indent_auto_switch_bullet": false,

maliayas avatar Feb 23 '15 08:02 maliayas

Hello,

The setting "mde.list_indent_auto_switch_bullet" : false, has stopped working. Whenever I tab a selection that has bullets in it, the leading characters change regardless of whether I have this set to true or false.

Did something change?

Let me know if I can troubleshoot.

Jon

jonathanmorgan avatar Aug 25 '15 21:08 jonathanmorgan

Also, the next item in the document that has the same leading character in the items that I indent or outdent also is changed, even though it is not within the selection that I indent or outdent.

jonathanmorgan avatar Aug 25 '15 21:08 jonathanmorgan

I've checked on ST build 3088 and it works fine. Is it possible that you are configuring the wrong settings file as there are 3 of them?

Also I cant verify your "next item bug". If you provide sample text and tell the exact cursor/selection status, we can look in more detail.

maliayas avatar Aug 25 '15 22:08 maliayas

Here is sample text:

    ### grading

    - grading

        - `nbgrader list --inbound` - instructor list of assignments that have been submitted
        - `nbgrader collect "<assignment>"` - pulls most recent submission of each assignment and places it in a folder for each student.
        - there is a 
        - `nbgrader formgrade` - web interface for human grading.

            - for problems sets, anonymizes and randomizes the problems.
            - lest instructor go through each notebook and grade or update automated grades any part of the notebook.

        - no way to export then re-import reponses and grades.
        - once grades are done - `nbgrader feedback` - renders feedback into HTML files, then places them in a certain place so that you can give them back to students.

    - jupyter hub + nbgrader

    - they are written to work together...

Select from "- grading" down to before the hyphen in "- they are written to work together...", then hit tab.

In my Sublime, even when a file that contains just this text has not yet been saved as markdown, hitting tab there causes the line on which the cursor ends up to be indented along with the selection, so for that, looks like the line with the cursor is included in the selection, even if there is nothing selected on the line. That explains the next item thing (in my environment, at least).

When the file has been saved as markdown, hitting tab causes all the list item characters to change, including the one on the line where the cursor is.

The setting line where I've set the value is "Settings - User". My file:

    {
        "color_scheme": "Packages/Color Scheme - Default/Espresso Libre.tmTheme",
        "line_numbers": true,
        "mde.list_indent_auto_switch_bullet": false,
        "translate_tabs_to_spaces": true
    }

I've also had it intermittently start to insert gobbledy-gook other than what I copied when I paste into a list item that is nested two or three levels deep inside a hierarchical list like this, just in general - with no text selected, but only sometimes, and I can't reliably reproduce it. Do you think it would be worth trying to re-install Sublime, or wiping all the config files and re-installing? This is happening on both my machines, though. Maybe it is a conflict with another plugin? Sublime 3 build 3083.

Thanks,

Jon

jonathanmorgan avatar Aug 25 '15 23:08 jonathanmorgan

I checked it too (with the text you provided and the selection range you recommended) and found no problem. I can set mde.list_indent_auto_switch_bullet to false to disable the item bullet from changing.

I can confirm that when the empty line at the end of the selection will cause that line to be indented as well. If you see this as a bug, we can fix it.

P.S. If you have time & can read python & willing to debug this problem, you can git clone this repo to your packages folder and see how indent_list_muiltiitem.py is executed. The standard output is directed to a console window opened by `Ctrl+``.

felixhao28 avatar Aug 27 '15 07:08 felixhao28

OK. Thanks for checking. I will grab a copy of the repo and see if I can tell what is going on. It might take me a day or two. Thanks for the guidance on where that code lives, and again for the sanity check on a different setup. I appreciate it!

jonathanmorgan avatar Aug 27 '15 12:08 jonathanmorgan

For "next item", I wouldn't worry about it. It is the bahavior I'm seeing independent of your plugin, so if that is just how sublime works, no sense in changing that in a single plugin, and it might even be related to whatever else I've got going on (I've been using sublime for years, haven't done a fresh clean re-install in a while on either machine, so I might have just built up some cruft in both my machines).

jonathanmorgan avatar Aug 27 '15 12:08 jonathanmorgan

Well, I tried a clean fresh install of Sublime Text 3 build 3083 with no other plugins but Package Control and MarkdownEditing on OS X, set

    "mde.list_indent_auto_switch_bullet": false

in Settings - User (from the main sublime menu) and it is still doing this. I'll grab your source and see if I can figure out what is going on.

jonathanmorgan avatar Aug 29 '15 17:08 jonathanmorgan

OK. So, in indent_list_muiltiitem.py, at line 31, the following line:

    if self.view.settings().get("mde.list_indent_auto_switch_bullet", True):

is always returning true (I put a print of "TRUE" just after the statement, inside the conditional, and added an "else" and printed "FALSE" there - it never printed "FALSE" in a minute or so of testing).

I grep-ed for the mde.list_indent_auto_switch_bullet setting in my "Sublime Text 3" Application Support folder:

    /Users/jonathanmorgan/Library/Application Support/Sublime Text 3

It found the following files with this setting:

    ./Packages/MarkdownEditing/Markdown (Standard).sublime-settings:37: "mde.list_indent_auto_switch_bullet": true,
    ./Packages/MarkdownEditing/Markdown.sublime-settings:48:    "mde.list_indent_auto_switch_bullet": true,
    ./Packages/MarkdownEditing/MultiMarkdown.sublime-settings:42:   "mde.list_indent_auto_switch_bullet": true,
    ./Packages/User/Preferences.sublime-settings:9: "mde.list_indent_auto_switch_bullet": false,

I have that setting set to false in the User settings, it is set to true in those other files. Am I not setting this in the correct place? In the past, though I forget when this problem started occurring, setting this setting in ./Packages/User/Preferences.sublime-settings did the trick. Now it does not. Do I need to go further down the settings files chain?

jonathanmorgan avatar Aug 29 '15 18:08 jonathanmorgan

Ah, I see the problem. The priorities of preference files in Sublime Text come in this order (at least for now):

  1. Language user setting (Preferences -> Package Settings -> Markdown Editing -> *** - User A.K.A Preferences -> Settings - More -> Syntax Specific - User)
  2. Language default setting (Preferences -> Package Settings -> Markdown Editing -> *** - Default)
  3. Global user setting (Preferences -> Settings - User)
  4. Global default setting (Preferences -> Settings - Default)

You are setting mde.list_indent_auto_switch_bullet to false in Global user setting but Language default setting overrides that to true. You need to override that by putting the setting to Language user setting instead.

felixhao28 avatar Aug 31 '15 09:08 felixhao28

Opening a markdown document, then setting this in the file opened by:

Preferences -> Settings - More -> Syntax Specific - User

did the trick (file: "Markdown.sublime-settings" - ~/Library/Application Support/Sublime Text 3/Packages/User/Markdown.sublime-settings).

If you were to go through the "Preferences -> Package Settings -> Markdown Editing..." path, that file lives in:

Preferences -> Package Settings -> Markdown Editing -> Markdown GFM Settings - User

(Documenting in case I look this up again later)

Thanks for the help! Much appreciated, as always!

jonathanmorgan avatar Aug 31 '15 14:08 jonathanmorgan