Comments (10)
@mkhl We could extend the exclusive
feature of markers and allow for exclusiveStart
/exclusiveEnd
or exclusiveHead
/exclusiveTail
. Putting it on the marker makes more sense to me than putting it on the range, which is a really simple construct and doesn't even encode directionality.
from text-document.
@lee-dohm This behaviour is the cause of atom/snippets#15, are you sure that feedback
is the correct classification?
from text-document.
Summary
I’ll try to extend Range
to indicate whether its ends are open or closed to mitigate this problem.
Context
A Marker
marks a buffer range represented by a Range
object. A Range
is comprised of two Point
s (row/column pairs) indicating the starting and ending buffer coordinates. Those coordinates are cursor positions, i.e. each denotes a point between two characters in the buffer.
Proposal
I propose extending Range
to include information about whether its ends are open or closed, similar to how Ranges are represented in Guava (see also).
Ranges will be closed by default, i.e. without code changes they’ll keep their current behaviour of including (covering) the insertion points at both ends.
This gives packages options to refine which points their markers and ranges include.
Snippets can then create open/closed ranges, i.e. ranges that include the insertion point at the end but not at the start. That should solve atom/snippets#15.
I’ll go ahead and try to implement this. In the meantime I welcome discussion about how we should handle this.
from text-document.
Have you tried the exclusive
option that can be passed to set range. We added it a while ago but didn't document it because we were unsure about keeping it. I've decided to just commit to it and document it. It won't allow you to control each endpoint exclusively, but I think it could solve your problem. I'm going to close the issue on that assumption. We can reopen if I'm wrong.
from text-document.
If I understand exclusive
correctly, using it for snippets would create a more severe issue where one can’t append text to markers.
If I insert a snippet ${1:foo} ${2:bar}
and type asd
, the a
would replace foo
but the s
would, due to exclusive
, not be appended to the placeholder. Also because the keystrokes exit the placeholder’s marker I expect that the snippet would be considered finished and that I wouldn’t be able to tab to the next placeholder.
That might be misunderstanding on my part though.
from text-document.
Wouldn't a similar problem apply with a Range that had open endpoints?
from text-document.
An open Range would be the same as an exclusive Range and would have the same problem.
A left-open Range would exclude the beginning but not the end. It would have different problems (but, in my opinion, fewer and more contrived ones).
from text-document.
Ideally I’d like if, given a snippet
${1:abc}${2:def}
$2$1
Atom would distinguish the situations where I
- activate placeholder 1, hit →, enter text (text should appear at the end of line 2)
- activate placeholder 2, hot ←, enter text (text should appear at the beginning of line 1)
But I don’t think we can do that by extending Range.
from text-document.
@mkhl I've actually archived this repository because it's not in use. Maybe it would be good to open an issue on snippets describing the surface level problem or an issue on text-buffer proposing the feature. Unfortunately, I can't change course immediately to make this addition, but I do think you raise good points and it would be worthwhile to do once bigger issues are dealt with in our text layer.
from text-document.
All repositories in the atom-archive organization are unmaintained and deprecated. Because of this, we are archiving this repository and closing all issues and pull requests. Thanks very much for your support and contributions!
from text-document.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from text-document.