Coder Social home page Coder Social logo

Comments (8)

bigfive avatar bigfive commented on June 7, 2024

What do you mean by fails?
The current behaviour is that is selects the nearest selectable text position (so it would snap to the beginning or end of a hard tab). Is that not what you are experiencing?

from atom-sublime-select.

ecanuto avatar ecanuto commented on June 7, 2024

Well, it depends what you call "selectable". Here, it works perfect with all lines that don't contains "tab" character like on last 3 lines of my sample.

Try it, type 123456 and then , 123456 and last type 123456. Selection on third line don't works as espected.

Please let me know if you can't reproduce behavior then I can try to make a video.

Btw, good job. This extension is what is missing on default Atom instalation!

from atom-sublime-select.

efc-awebb avatar efc-awebb commented on June 7, 2024

I use tabs that are 4 positions (spaces) wide. Actual tabs, not tabs-to-spaces.

When I attempt to use column selection on lines that contain tabs, it calculates the correct column positions from which to select, but then applies that as a character position (with a tab counting as a single character).

Imgur

from atom-sublime-select.

chowyuncat avatar chowyuncat commented on June 7, 2024

I think there should be an option always keep a rectangular selection, never selecting anything past the mouse cursor's column, and additionally selecting rows and columns where text doesn't exist.

from atom-sublime-select.

bigfive avatar bigfive commented on June 7, 2024

Oh I see!
Yeah I'm able to replicate that.

I would actually consider that a bug in the atom API. It doesn't consider tab size when reporting columns, or setting ranges by column number.

I'll have a look through the API and see if there is another way that takes hard-tabs into consideration, otherwise I'll have a look at detecting the number of hard-tabs on each line that is selected and accounting for them when handling column numbers (eek).

from atom-sublime-select.

efc-awebb avatar efc-awebb commented on June 7, 2024

I looked into the TextBuffer API methods and didn't find anything that might be useful here besides the methods you're already using. I do have some rough draft logic in place that attempts to calculate the correct placement. I haven't looked into a way to retrieve the user's tab settings, but I suspect that won't be too hard - for now, it's hard-coded to 4-width hard tabs.

It's messy, but it's an improvement over the current behavior in terms of hard tab environments. I'll put up a gist tomorrow and hopefully it'll provide a decent starting point for building out a more robust selection handler.

from atom-sublime-select.

bigfive avatar bigfive commented on June 7, 2024

Actually I just released a new patch that should fix this.

I was confusing buffer ranges with screen ranges.
As far as I can tell:
buffer column = number of text characters from the left
screen column = number of mono spaced columns from the left

Atom API has a nice bufferRangeForScreenRange method. Hey presto!

from atom-sublime-select.

efc-awebb avatar efc-awebb commented on June 7, 2024

Hah! That's exactly what I planned on writing myself to clean up my code. Fantastic.

from atom-sublime-select.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.