Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong autocorrect when autodetecting file names #5193

Open
JosephBARBIERDARNAL opened this issue Oct 29, 2024 · 9 comments
Open

wrong autocorrect when autodetecting file names #5193

JosephBARBIERDARNAL opened this issue Oct 29, 2024 · 9 comments

Comments

@JosephBARBIERDARNAL
Copy link

System details:

Positron and OS details:

Positron Version: 2024.08.0 (Universal) build 48
Code - OSS Version: 1.91.0
Commit: ed616b3
Date: 2024-08-19T04:26:51.868Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.6.0

Interpreter details:

Python 3.11.5

Describe the issue:

When the editor suggests a filename, it adds its full name to where my cursor is, instead of replacing what I've already written, which makes it unusable for accepting suggestions.

There are several cases that I've recorded for simplicity's sake, as they're not easy to describe in writing.

Context: I want to open a file called countries.geojson, either in the data/ directory (case 1) or in the root directory (cases 2 and 3).

  • case 1 (does not work as expected)

Image

  • case 2 (does work as expected)

Image

  • case 3 (does not work as expected)

Image

Note: I haven't managed to reproduce it in VS code or in an R environment.

Steps to reproduce the issue:

import geopandas as gpd
from shapely.geometry import shape

geojson_data = {
    "type": "FeatureCollection",
    "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}},
    "features": [
        {
            "type": "Feature",
            "properties": {"name": "Fiji"},
            "geometry": {
                "type": "MultiPolygon",
                "coordinates": [
                    [
                        [
                            [180.0, -16.067132663642447],
                            [180.0, -16.555216566639196],
                            [180.0, -16.555216566639196],
                            [180.0, -16.555216566639196],
                        ]
                    ],
                    [
                        [
                            [178.12557, -17.50481],
                            [178.3736, -17.33992],
                            [178.3736, -17.33992],
                            [178.3736, -17.33992],
                        ]
                    ],
                ],
            },
        },
        {
            "type": "Feature",
            "properties": {"name": "Tanzania"},
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [33.903711197104528, -0.95],
                        [34.07262, -1.05982],
                        [37.69869, -3.09699],
                        [37.69869, -3.09699],
                    ]
                ],
            },
        },
    ],
}


features = geojson_data["features"]
geometries = [shape(feature["geometry"]) for feature in features]
properties = [feature["properties"] for feature in features]
gdf = gpd.GeoDataFrame(properties, geometry=geometries)
gdf.to_file("countries.geojson", driver="GeoJSON")

# try writing "countries.geojson" here
gpd.read_file()

Expected or desired behavior:

Instead of data/countries.countries.geojson, I would like the replacement to be data/countries.geojson.

@juliasilge
Copy link
Contributor

juliasilge commented Oct 29, 2024

I also observe this problem in Python.

That file path completion comes from Jedi upstream; I don't currently see an issue open about this bug.

I believe the file path expansion happens here.

@JosephBARBIERDARNAL
Copy link
Author

JosephBARBIERDARNAL commented Oct 30, 2024

@juliasilge Do you want me to open an issue on the Jedi repo? Or will Positron handle the problem directly?

@juliasilge
Copy link
Contributor

@JosephBARBIERDARNAL We will likely want to open up an issue over there, but it would be better to show the bug in a more straightforward usage than Positron, like using Jedi in VS Code (change the setting "Python: Language Server" from default to Jedi) or emacs or similar. I did just confirm I see the same bug in VS Code when using Jedi. No expectation but if you are up for it, that would be most welcome!

@jthomasmock
Copy link
Contributor

jthomasmock commented Nov 4, 2024

Added an issue + example over in Jedi repo including a screencast of the same behavior in VS Code when using Jedi as the LSP.

pappasam/jedi-language-server#325

@jthomasmock
Copy link
Contributor

jthomasmock commented Nov 5, 2024

The Jedi LSP folks are planning to remove path completions on their side, so for now, I would probably try an extension for now.

I did try the Path Intellisense and Path Autocomplete extensions which seems to resolve the issue when auto-completing at the . -- note that I had to start using Ctrl+Space to initiate the auto-complete rather than Tab

I would probably lean towards: https://open-vsx.org/extension/christian-kohler/path-intellisense

@etiennebacher

This comment has been minimized.

@juliasilge

This comment has been minimized.

@seeM seeM self-assigned this Jan 10, 2025
seeM added a commit that referenced this issue Jan 16, 2025
Addresses #5193.

### Release Notes

#### New Features

- N/A

#### Bug Fixes

- Fixed path completions for Python interpreters (#5193).


### QA Notes

See the linked issue.
@seeM
Copy link
Contributor

seeM commented Jan 17, 2025

@jthomasmock even though path completions were removed from jedi-language-server, we are still completing paths after upgrading just because of the way we've extended their code (we had to copy-paste and edit the whole completions method).

The underlying jedi library handles path completions quite well, so I decided to make the relatively simple fix (#6002) instead of following jedi-language-server and removing path completions entirely.

I suggest we decide whether to remove path completions from our Python language server when we tackle #5345.

@jthomasmock
Copy link
Contributor

@jthomasmock even though path completions were removed from jedi-language-server, we are still completing paths after upgrading just because of the way we've extended their code (we had to copy-paste and edit the whole completions method).

The underlying jedi library handles path completions quite well, so I decided to make the relatively simple fix (#6002) instead of following jedi-language-server and removing path completions entirely.

I suggest we decide whether to remove path completions from our Python language server when we tackle #5345.

Agreed -- thanks Wasim. I understand the Jedi team's choice to remove the capability, but I think our users will expect path/file completions (and accurate completions!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants