Skip to content

C# Collection Item Selection #1195

Open
@JohnEfford

Description

@JohnEfford

"Take item .." is not working correctly, I would expect take item to take the entire item but "take item 4" select just 4 so it looks like tree sitter is looking at a token separated by coma:

public readonly Collection<Point> Points = new()
{
    new Point(1, 4), 
    new Point(2, 3),
    new Point(3, 7),
};

Expected '''new Point(1, 4)``` and for deletion ''new Point(1, 4),"""

C# also allows tuple collections:

public readonly Collection<(int, Point)> Badger= new () 
{
    (10, new Point(1, 4)),
};

The initialiser syntax may also look like this for collections, the type is explicitly defined:

public readonly Collection<(int, Point)> Badger= new  Collection<(int, Point)> 
{
    (10, new Point(1, 4)),
};

Other types which can use collection initialisation are:

public readonly List<(int, Point)> BadgerList = new()
{
    (10, new Point(1, 4)),
};

public readonly (int, Point)[] BadgerArray = 
{
    (10, new Point(1, 4)),
    (10, new Point(1, 2)),
};

public readonly HashSet<int> Hash = new() { 1, 2, 3 };

Dictionary Type

Dictionaries are maps/lookups so the string below should be selectable with take key, and item should be the key and the we agreed that the item would be the whole value {"Fit", new Point(1, 4) },

public readonly Dictionary<string,Point> PointLookup = new()
{
    //Key?
    {"Fit", new Point(1, 4) },
    { "Second", new Point(2, 4) },
    { "Third", new Point(3, 4) },
};

Take map

Take map for:

public readonly List<(int, Point)> BadgerList = new()
{
    (10, new Point(1, 4)),
};

Selects

{
    (10, new Point(1, 4)),
};

@AndreasArvidsson thought this should select:

new()
{
    (10, new Point(1, 4)),
};

I agree that this would be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions