vscode-code-outline icon indicating copy to clipboard operation
vscode-code-outline copied to clipboard

Feature Request: Change tree item name with setting

Open ppggff opened this issue 7 years ago • 5 comments

When using with markdown file, all symbols displayed in same level with different number of #. (It's better if vscode can produce a better symbol tree for markdown file, but it didn't now...)

It looks like:

test1

It will be better if I can replace # with something looks more clear. I tried to edit the symbolOutline.js with some simple change in getTreeItem():

name.replace(/^(##|#)/, '').replace(/^#+/, function(m){ return m.replace(/#/g, '  ');})

Then the outline tree looks like:

test

I hope it could be something in setting that user can use JavaScript to change item's name.

ppggff avatar Jul 26 '17 09:07 ppggff

I'd rather avoid special-casing certain formats.

patrys avatar Jul 26 '17 09:07 patrys

@patrys Yes. I think this setting could be used in a more generic way:

  • Change "AxxxBxxxCxxx" to "axxx_bxxx_cxxx"
  • Trim useless prefix
  • Some kind of translating
  • ...

ppggff avatar Jul 26 '17 09:07 ppggff

@patrys Do you consider to accept PR for this issue?

ppggff avatar Jul 27 '17 13:07 ppggff

I'm open for all proposals but I'd like to discuss this through before you spend time on an implementation. I don't think it's a good idea for someone to have to write code in setting files. JSON is not really suitable to express logic and evaluating random strings is a bad idea as there is no way to prevent the function from erasing all of your files (and it's not uncommon to track workspace config in git).

patrys avatar Jul 27 '17 13:07 patrys

How about user can provide multiple pairs string to run replace for item name?

    "ItemNameReplace" : [
        {"pattern":"/^(##|#)/", "replacement":""},
        {"pattern":"/^#/", "replacement" : " "}
    ]

ppggff avatar Jul 28 '17 03:07 ppggff