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

view.sel() appears to not handle multiple views into a file correctly #3668

Closed
RobinWragg opened this issue Oct 4, 2020 · 2 comments
Closed

Comments

@RobinWragg
Copy link

Description

view.sel() seems to always return the selections of the primary view into a file, even when called on a secondary view into the file.

Steps to reproduce

  1. Install this plugin, which prints the current line to the console when a selection is modified:
import sublime
import sublime_plugin

class HighlightLongLine(sublime_plugin.ViewEventListener):
	def on_selection_modified(self):
		for region in self.view.sel():
			line = self.view.line(region.b)
			print(self.view.substr(line))
  1. Open a file, then open another view into the same file, which I'll call View A and B.
  2. Check the console output when moving the caret in each file.

Expected behavior

When browsing View A, the current line of View A will be printed to the console.
When browsing View B, the current line of View B will be printed to the console.

Actual behavior

When browsing View A, the current line of View A will be printed to the console twice.
When browsing View B, the current line of View A will be printed to the console twice.
It is not possible to obtain the selections from View B.

Environment

  • Build: 3211
  • Operating system and version: Windows 10

Thanks for your time.

@keith-hall
Copy link
Collaborator

Thanks for reporting. I believe this is a duplicate of #289

@RobinWragg
Copy link
Author

I see, it seems on_selection_modified() is being passed the wrong view.

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

No branches or pull requests

2 participants